diff options
author | Loïc Hoguin <[email protected]> | 2013-01-29 21:24:04 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2013-01-29 21:24:04 +0100 |
commit | ec52b4f4df70a114bca56a19535739ae3788166a (patch) | |
tree | 092ef2ed715873bc2595a409d43d04c9dba956c1 /test/rest_created_path_resource.erl | |
parent | fd5a977a39ec99d0aa57a2864f91cca7af5c67d6 (diff) | |
parent | 8a798014e980d596e631cf5f24957ee15f9a1ac4 (diff) | |
download | cowboy-ec52b4f4df70a114bca56a19535739ae3788166a.tar.gz cowboy-ec52b4f4df70a114bca56a19535739ae3788166a.tar.bz2 cowboy-ec52b4f4df70a114bca56a19535739ae3788166a.zip |
Merge branch 'rest_post_created_path' of https://github.com/treetopllc/cowboy
Diffstat (limited to 'test/rest_created_path_resource.erl')
-rw-r--r-- | test/rest_created_path_resource.erl | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/rest_created_path_resource.erl b/test/rest_created_path_resource.erl new file mode 100644 index 0000000..5ad8cfc --- /dev/null +++ b/test/rest_created_path_resource.erl @@ -0,0 +1,35 @@ +-module(rest_created_path_resource). +-export([init/3]). +-export([allowed_methods/2]). +-export([content_types_provided/2]). +-export([get_text_plain/2]). +-export([post_is_create/2]). +-export([content_types_accepted/2]). +-export([post_text_plain/2]). +-export([created_path/2]). + +init(_Transport, _Req, _Opts) -> + {upgrade, protocol, cowboy_rest}. + +allowed_methods(Req, State) -> +{[<<"HEAD">>, <<"GET">>, <<"POST">>], Req, State}. + +content_types_provided(Req, State) -> + {[{{<<"text">>, <<"plain">>, []}, get_text_plain}], Req, State}. + +get_text_plain(Req, State) -> + {<<"This is REST!">>, Req, State}. + +post_is_create(Req, State) -> + {true, Req, State}. + +content_types_accepted(Req, State) -> + {[{{<<"text">>, <<"plain">>, []}, post_text_plain}], Req, State}. + +post_text_plain(Req, State) -> + {true, Req, State}. + +created_path(Req, State) -> + {<<"/created">>, Req, State}. + + |