Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gleam-lang/hackney
🪝 Make requests to HTTP servers with Hackney
https://github.com/gleam-lang/hackney
erlang gleam http-client
Last synced: 28 days ago
JSON representation
🪝 Make requests to HTTP servers with Hackney
- Host: GitHub
- URL: https://github.com/gleam-lang/hackney
- Owner: gleam-lang
- License: apache-2.0
- Created: 2021-12-26T15:46:54.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-01-24T08:29:40.000Z (11 months ago)
- Last Synced: 2024-03-15T03:34:45.845Z (9 months ago)
- Topics: erlang, gleam, http-client
- Language: Gleam
- Homepage:
- Size: 31.3 KB
- Stars: 23
- Watchers: 4
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-gleam - gleam_hackney - [📚](https://hexdocs.pm/gleam_hackney/) - Gleam bindings to the Hackney HTTP client (Packages / HTTP Clients)
README
# Hackney
![CI](https://github.com/gleam-lang/hackney/workflows/test/badge.svg?branch=main)Bindings to Erlang's `hackney` HTTP client.
```gleam
import gleam/result.{try}
import gleam/hackney
import gleam/http.{Get}
import gleam/http/request
import gleam/http/response
import gleeunit/shouldpub fn main() {
// Prepare a HTTP request record
let assert Ok(request) =
request.to("https://test-api.service.hmrc.gov.uk/hello/world")// Send the HTTP request to the server
use response <- try(
request
|> request.prepend_header("accept", "application/vnd.hmrc.1.0+json")
|> hackney.send
)// We get a response record back
response.status
|> should.equal(200)response
|> response.get_header("content-type")
|> should.equal(Ok("application/json"))response.body
|> should.equal("{\"message\":\"Hello World\"}")Ok(response)
}
```## Installation
```shell
gleam add gleam_hackney
```