Current section
Files
Jump to
Current section
Files
src/flwr_oauth2@http_headers.erl
-module(flwr_oauth2@http_headers).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/flwr_oauth2/http_headers.gleam").
-export([set_bearer/2, encode_base64/2, set_basic/3]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(" Helper module to collect useful setters for HTTP headers, such as the authorization header.\n").
-file("src/flwr_oauth2/http_headers.gleam", 9).
-spec set_bearer(gleam@http@request:request(FKF), binary()) -> gleam@http@request:request(FKF).
set_bearer(Req, Bearer_token) ->
_pipe = Req,
gleam@http@request:set_header(
_pipe,
<<"authorization"/utf8>>,
<<"Bearer "/utf8, Bearer_token/binary>>
).
-file("src/flwr_oauth2/http_headers.gleam", 29).
-spec encode_base64(binary(), binary()) -> binary().
encode_base64(Client_id, Client_secret) ->
_pipe = (<<<<Client_id/binary, ":"/utf8>>/binary, Client_secret/binary>>),
_pipe@1 = gleam_stdlib:identity(_pipe),
gleam_stdlib:base64_encode(_pipe@1, true).
-file("src/flwr_oauth2/http_headers.gleam", 17).
-spec set_basic(gleam@http@request:request(FKI), binary(), binary()) -> gleam@http@request:request(FKI).
set_basic(Req, Client_id, Client_secret) ->
_pipe = Req,
gleam@http@request:set_header(
_pipe,
<<"authorization"/utf8>>,
<<"Basic "/utf8, (encode_base64(Client_id, Client_secret))/binary>>
).