aboutsummaryrefslogtreecommitdiffstats
path: root/test/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'test/handlers')
-rw-r--r--test/handlers/create_resource_h.erl28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/handlers/create_resource_h.erl b/test/handlers/create_resource_h.erl
new file mode 100644
index 0000000..f82e610
--- /dev/null
+++ b/test/handlers/create_resource_h.erl
@@ -0,0 +1,28 @@
+-module(create_resource_h).
+
+-export([init/2]).
+-export([allowed_methods/2]).
+-export([resource_exists/2]).
+-export([content_types_accepted/2]).
+-export([from_text/2]).
+
+init(Req, Opts) ->
+ {cowboy_rest, Req, Opts}.
+
+allowed_methods(Req, State) ->
+ {[<<"POST">>], Req, State}.
+
+resource_exists(Req, State) ->
+ {true, Req, State}.
+
+content_types_accepted(Req, State) ->
+ {[{{<<"application">>, <<"text">>, []}, from_text}], Req, State}.
+
+from_text(Req=#{qs := Qs}, State) ->
+ NewURI = [cowboy_req:uri(Req), "/foo"],
+ case Qs of
+ <<"created">> ->
+ {{created, NewURI}, Req, State};
+ <<"see_other">> ->
+ {{see_other, NewURI}, Req, State}
+ end.