mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-16 05:00:24 +00:00
Add a cowboy_req:to_list/1 function
Removes a lot of duplicate code when printing error messages.
This commit is contained in:
parent
9b5cbb5000
commit
bb4bd9ac96
4 changed files with 14 additions and 8 deletions
|
@ -78,6 +78,7 @@
|
|||
|
||||
%% Misc API.
|
||||
-export([compact/1]).
|
||||
-export([to_list/1]).
|
||||
-export([transport/1]).
|
||||
|
||||
-include("http.hrl").
|
||||
|
@ -816,6 +817,11 @@ compact(Req) ->
|
|||
bindings=undefined, headers=[],
|
||||
p_headers=[], cookies=[]}.
|
||||
|
||||
%% @doc Convert the Req object to a list of key/values.
|
||||
-spec to_list(req()) -> [{atom(), any()}].
|
||||
to_list(Req) ->
|
||||
lists:zip(record_info(fields, http_req), tl(tuple_to_list(Req))).
|
||||
|
||||
%% @doc Return the transport module and socket associated with a request.
|
||||
%%
|
||||
%% This exposes the same socket interface used internally by the HTTP protocol
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue