Auto-indexing service and GraphQL API for AT Protocol Records
quickslice.slices.network/
atproto
gleam
graphql
1import gleam/bytes_tree.{type BytesTree}
2import gleam/hackney
3import gleam/http/request.{type Request}
4import gleam/http/response.{type Response}
5import gleam/httpc
6
7const user_agent = "quickslice"
8
9/// Send an HTTP request with the quickslice user-agent header.
10/// Use this instead of httpc.send directly.
11pub fn send(req: Request(String)) -> Result(Response(String), httpc.HttpError) {
12 req
13 |> request.set_header("user-agent", user_agent)
14 |> httpc.send
15}
16
17/// Send an HTTP request with binary body using httpc.
18/// Use this instead of httpc.send_bits directly.
19pub fn send_bits(
20 req: Request(BitArray),
21) -> Result(Response(BitArray), httpc.HttpError) {
22 req
23 |> request.set_header("user-agent", user_agent)
24 |> httpc.send_bits
25}
26
27/// Send an HTTP request using hackney.
28/// Use this instead of hackney.send directly.
29pub fn hackney_send(
30 req: Request(String),
31) -> Result(Response(String), hackney.Error) {
32 req
33 |> request.set_header("user-agent", user_agent)
34 |> hackney.send
35}
36
37/// Send an HTTP request with binary body using hackney.
38/// Use this instead of hackney.send_bits directly.
39pub fn hackney_send_bits(
40 req: Request(BytesTree),
41) -> Result(Response(BitArray), hackney.Error) {
42 req
43 |> request.set_header("user-agent", user_agent)
44 |> hackney.send_bits
45}