-module(internal@http@request). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([get/2]). -spec get(gleam@option:option(binary()), binary()) -> {ok, gleam@http@response:response(binary())} | {error, internal@http@error:error()}. get(Resource, Path) -> Split_path = begin _pipe = Path, gleam@string:split(_pipe, <<","/utf8>>) end, Path@1 = case {Resource, Split_path} of {{some, R}, [P | Rest]} -> _pipe@1 = [P, R | Rest], gleam@string:join(_pipe@1, <<"/"/utf8>>); {{some, R@1}, _} -> <<<>/binary, R@1/binary>>; {none, _} -> _pipe@2 = Split_path, gleam@string:join(_pipe@2, <<"/"/utf8>>) end, _pipe@3 = gleam@http@request:new(), _pipe@4 = gleam@http@request:set_host(_pipe@3, <<"pokeapi.co/api/v2"/utf8>>), _pipe@5 = gleam@http@request:set_path(_pipe@4, Path@1), _pipe@6 = gleam@http@request:set_header( _pipe@5, <<"Content-Type"/utf8>>, <<"application/json"/utf8>> ), _pipe@7 = gleam@hackney:send(_pipe@6), gleam@result:replace_error(_pipe@7, request_error).