aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2011-10-13 16:16:53 +0200
committerLoïc Hoguin <[email protected]>2011-10-13 16:16:53 +0200
commit81cc99d10bab86369f4ae7ea0db948ffad1239d0 (patch)
treeafccf71704b98251a89b3fa042ca2225ecf15520 /src
parent2a324aca3a589c13b4d73f03f8da65cc3ee36b20 (diff)
downloadcowboy-81cc99d10bab86369f4ae7ea0db948ffad1239d0.tar.gz
cowboy-81cc99d10bab86369f4ae7ea0db948ffad1239d0.tar.bz2
cowboy-81cc99d10bab86369f4ae7ea0db948ffad1239d0.zip
Add shortcuts to reply functions
New functions are reply/2, reply/3, chunked_reply/2 in cowboy_http_req.
Diffstat (limited to 'src')
-rw-r--r--src/cowboy_http_req.erl18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/cowboy_http_req.erl b/src/cowboy_http_req.erl
index 63b196e..a7b0533 100644
--- a/src/cowboy_http_req.erl
+++ b/src/cowboy_http_req.erl
@@ -37,7 +37,8 @@
]). %% Request Body API.
-export([
- reply/4, chunked_reply/3, chunk/2
+ reply/2, reply/3, reply/4,
+ chunked_reply/2, chunked_reply/3, chunk/2
]). %% Response API.
-export([
@@ -312,6 +313,16 @@ body_qs(Req) ->
%% Response API.
+%% @equiv reply(Status, [], [], Req)
+-spec reply(http_status(), #http_req{}) -> {ok, #http_req{}}.
+reply(Status, Req) ->
+ reply(Status, [], [], Req).
+
+%% @equiv reply(Status, Headers, [], Req)
+-spec reply(http_status(), http_headers(), #http_req{}) -> {ok, #http_req{}}.
+reply(Status, Headers, Req) ->
+ reply(Status, Headers, [], Req).
+
%% @doc Send a reply to the client.
-spec reply(http_status(), http_headers(), iodata(), #http_req{})
-> {ok, #http_req{}}.
@@ -332,6 +343,11 @@ reply(Status, Headers, Body, Req=#http_req{socket=Socket,
end,
{ok, Req#http_req{connection=RespConn, resp_state=done}}.
+%% @equiv chunked_reply(Status, [], Req)
+-spec chunked_reply(http_status(), #http_req{}) -> {ok, #http_req{}}.
+chunked_reply(Status, Req) ->
+ chunked_reply(Status, [], Req).
+
%% @doc Initiate the sending of a chunked reply to the client.
%% @see cowboy_http_req:chunk/2
-spec chunked_reply(http_status(), http_headers(), #http_req{})