aboutsummaryrefslogtreecommitdiffstats
path: root/doc/src/manual/cowboy_req.method.asciidoc
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2016-11-05 14:17:30 +0200
committerLoïc Hoguin <[email protected]>2016-11-05 14:17:30 +0200
commitfaca7866ed1c59cd41e11fcfc5a9f95378380497 (patch)
tree7e33284b3426083154b7a1d52ae5db8996212739 /doc/src/manual/cowboy_req.method.asciidoc
parent8fe700f341d324c44f6c5f196f8c699c85ee6d78 (diff)
downloadcowboy-faca7866ed1c59cd41e11fcfc5a9f95378380497.tar.gz
cowboy-faca7866ed1c59cd41e11fcfc5a9f95378380497.tar.bz2
cowboy-faca7866ed1c59cd41e11fcfc5a9f95378380497.zip
Partially update manual for the cowboy_req
Only the access functions have been modified so far.
Diffstat (limited to 'doc/src/manual/cowboy_req.method.asciidoc')
-rw-r--r--doc/src/manual/cowboy_req.method.asciidoc60
1 files changed, 60 insertions, 0 deletions
diff --git a/doc/src/manual/cowboy_req.method.asciidoc b/doc/src/manual/cowboy_req.method.asciidoc
new file mode 100644
index 0000000..bb3ad6e
--- /dev/null
+++ b/doc/src/manual/cowboy_req.method.asciidoc
@@ -0,0 +1,60 @@
+= cowboy_req:method(3)
+
+== Name
+
+cowboy_req:method - HTTP method
+
+== Description
+
+[source,erlang]
+----
+method(Req :: cowboy_req:req()) -> Method :: binary()
+----
+
+Return the request's HTTP method.
+
+The method can also be obtained using pattern matching:
+
+[source,erlang]
+----
+#{method := Method} = Req.
+----
+
+== Arguments
+
+Req::
+
+The Req object.
+
+== Return value
+
+The request's HTTP method is returned as a binary string.
+While methods are case sensitive, standard methods are
+always uppercase.
+
+== Changelog
+
+* *2.0*: Only the method is returned, it is no longer wrapped in a tuple.
+* *1.0*: Function introduced.
+
+== Examples
+
+.Ensure the request's method is GET
+[source,erlang]
+----
+<<"GET">> = cowboy_req:method(Req).
+----
+
+.Allow methods from list
+[source,erlang]
+----
+init(Req, State) ->
+ case lists:member(cowboy_req:method(Req), [<<"GET">>, <<"POST">>]) of
+ true -> handle(Req, State);
+ false -> method_not_allowed(Req, State)
+ end.
+----
+
+== See also
+
+link:man:cowboy_req(3)[cowboy_req(3)]