Current section
Files
Jump to
Current section
Files
src/shimmer@http@request.erl
-module(shimmer@http@request).
-compile(no_auto_import).
-export([new/2, new_with_auth/3, set_body/2]).
-spec new(gleam@http:method(), binary()) -> gleam@http@request:request(binary()).
new(Method, Path) ->
_pipe = gleam@http@request:new(),
_pipe@1 = gleam@http@request:set_method(_pipe, Method),
_pipe@2 = gleam@http@request:set_host(_pipe@1, <<"discord.com"/utf8>>),
_pipe@3 = gleam@http@request:set_path(
_pipe@2,
gleam@string:append(<<"/api/v10"/utf8>>, Path)
),
gleam@http@request:prepend_header(
_pipe@3,
<<"accept"/utf8>>,
<<"application/json"/utf8>>
).
-spec new_with_auth(gleam@http:method(), binary(), binary()) -> gleam@http@request:request(binary()).
new_with_auth(Method, Path, Token) ->
_pipe = new(Method, Path),
gleam@http@request:prepend_header(
_pipe,
<<"authorization"/utf8>>,
gleam@string:append(<<"Bot "/utf8>>, Token)
).
-spec set_body(gleam@http@request:request(binary()), binary()) -> gleam@http@request:request(binary()).
set_body(Request, Body) ->
_pipe = Request,
_pipe@1 = gleam@http@request:set_body(_pipe, Body),
gleam@http@request:prepend_header(
_pipe@1,
<<"content-type"/utf8>>,
<<"application/json"/utf8>>
).