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: about 1 month 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 (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-02-06T12:04:30.000Z (5 months ago)
- Last Synced: 2025-06-09T13:38:05.315Z (about 1 month ago)
- Topics: erlang, gleam, http-client
- Language: Gleam
- Homepage:
- Size: 32.2 KB
- Stars: 46
- Watchers: 3
- Forks: 6
- Open Issues: 3
-
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
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
```