Skip to content

Commit

Permalink
feat(#75) map scheme, host and port
Browse files Browse the repository at this point in the history
  • Loading branch information
albertocsouto committed Jul 2, 2024
1 parent 0dac504 commit f3a8d31
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/erf.erl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
-type path_parameter() :: {binary(), binary()}.
-type query_parameter() :: {binary(), binary()}.
-type request() :: #{
scheme := undefined | binary(),
host := undefined | binary(),
port := undefined | 1..65535,
path := [binary()],
path_parameters => [path_parameter()],
method := method(),
Expand Down
9 changes: 9 additions & 0 deletions src/erf_router.erl
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,9 @@ postprocess(_Request, {Status, RawHeaders, RawBody}) ->
Request :: erf:request(),
Reason :: term().
preprocess(Req) ->
Scheme = elli_request:scheme(Req),
Host = elli_request:host(Req),
Port = elli_request:port(Req),
Path = elli_request:path(Req),
Method = preprocess_method(elli_request:method(Req)),
QueryParameters = elli_request:get_args_decoded(Req),
Expand All @@ -797,6 +800,9 @@ preprocess(Req) ->
case njson:decode(RawBody) of
{ok, Body} ->
{ok, #{
scheme => Scheme,
host => Host,
port => Port,
path => Path,
method => Method,
query_parameters => QueryParameters,
Expand All @@ -809,6 +815,9 @@ preprocess(Req) ->
end;
_ContentType ->
{ok, #{
scheme => Scheme,
host => Host,
port => Port,
path => Path,
method => Method,
query_parameters => QueryParameters,
Expand Down

0 comments on commit f3a8d31

Please sign in to comment.