Skip to content

Commit

Permalink
feat: support with cowboy req
Browse files Browse the repository at this point in the history
  • Loading branch information
turtleDeng committed Mar 25, 2024
1 parent 1df1cbb commit ae1bd29
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/minirest_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ dispatch(Req, #{module := Mod, func := Fun, bindings := Bindings} = Route) ->
})),
reply(400, <<"Bad Request">>, Req);
Params ->
case erlang:apply(Mod, Fun, [Bindings, Params]) of
Params1 = case maps:get(with_cowboy_req, Route, false) of
true -> [Bindings, Params, Req];
false -> [Bindings, Params]
end,
case erlang:apply(Mod, Fun, Params1) of
{file, Headers, {sendfile, _, _, _} = SendFile} ->
Req1 = cowboy_req:reply(200, Headers, SendFile, Req),
#{pattern := [Type|_], name := Name} = Route,
Expand Down

0 comments on commit ae1bd29

Please sign in to comment.