aboutsummaryrefslogtreecommitdiffstats
path: root/doc/src/guide
diff options
context:
space:
mode:
authorAndrei Nesterov <[email protected]>2016-11-16 20:57:11 +0300
committerLoïc Hoguin <[email protected]>2017-05-01 17:31:56 +0200
commit0a181681223aead4043b2437fe493652db6e5f8a (patch)
tree807f4b07b0a1995f7c40af1fde1ad9b330a0ba31 /doc/src/guide
parentfb4bd38ffd2c330cbd677d958477aa909210a0b3 (diff)
downloadgun-0a181681223aead4043b2437fe493652db6e5f8a.tar.gz
gun-0a181681223aead4043b2437fe493652db6e5f8a.tar.bz2
gun-0a181681223aead4043b2437fe493652db6e5f8a.zip
Add support for choosing a process to reply to
Diffstat (limited to 'doc/src/guide')
-rw-r--r--doc/src/guide/http.asciidoc21
-rw-r--r--doc/src/guide/protocols.asciidoc2
-rw-r--r--doc/src/guide/websocket.asciidoc4
3 files changed, 21 insertions, 6 deletions
diff --git a/doc/src/guide/http.asciidoc b/doc/src/guide/http.asciidoc
index 465a4c5..e856fb1 100644
--- a/doc/src/guide/http.asciidoc
+++ b/doc/src/guide/http.asciidoc
@@ -45,7 +45,7 @@ handling of responses will be explained further on.
==== GET and HEAD
-Use `gun:get/{2,3}` to request a resource.
+Use `gun:get/{2,3,4}` to request a resource.
.GET "/organizations/ninenines"
@@ -64,7 +64,7 @@ Note that the list of headers has the field name as a binary.
The field value is iodata, which is either a binary or an
iolist.
-Use `gun:head/{2,3}` if you don't need the response body.
+Use `gun:head/{2,3,4}` if you don't need the response body.
.HEAD "/organizations/ninenines"
@@ -101,7 +101,7 @@ desirable. The request body of a PATCH method may be a partial
representation or a list of instructions on how to update the
resource.
-The `gun:post/4`, `gun:put/4` and `gun:patch/4` functions
+The `gun:post/{4,5}`, `gun:put/{4,5}` and `gun:patch/{4,5}` functions
take a body as their fourth argument. These functions do
not require any body-specific header to be set, although
it is always recommended to set the content-type header.
@@ -171,7 +171,7 @@ do_sendfile(ConnPid, StreamRef, IoDevice) ->
==== DELETE
-Use `gun:delete/{2,3}` to delete a resource.
+Use `gun:delete/{2,3,4}` to delete a resource.
.DELETE "/organizations/ninenines"
@@ -211,7 +211,7 @@ StreamRef = gun:options(ConnPid, "*").
==== Requests with an arbitrary method
-The `gun:request/{4,5}` function can be used to send requests
+The `gun:request/{4,5,6}` function can be used to send requests
with a configurable method name. It is mostly useful when you
need a method that Gun does not understand natively.
@@ -360,3 +360,14 @@ gun:flush(ConnPid).
[source,erlang]
gun:flush(StreamRef).
+
+=== Redirecting responses to a different process
+
+Gun allows you to specify which process will handle responses
+to a request via the `reply_to` request option.
+
+.GET "/organizations/ninenines" to a different process
+
+[source,erlang]
+StreamRef = gun:get(ConnPid, "/organizations/ninenines", [],
+ #{reply_to => Pid}).
diff --git a/doc/src/guide/protocols.asciidoc b/doc/src/guide/protocols.asciidoc
index 2180c5b..5e3b273 100644
--- a/doc/src/guide/protocols.asciidoc
+++ b/doc/src/guide/protocols.asciidoc
@@ -10,7 +10,7 @@ sends a request, the server sends back a response.
Gun provides convenience functions for performing GET, HEAD,
OPTIONS, POST, PATCH, PUT, and DELETE requests. All these
-functions are aliases of `gun:request/{4,5}` for each respective
+functions are aliases of `gun:request/{4,5,6}` for each respective
methods. Gun also provides a `gun:data/4` function for streaming
the request body.
diff --git a/doc/src/guide/websocket.asciidoc b/doc/src/guide/websocket.asciidoc
index 4869a2e..f99dea7 100644
--- a/doc/src/guide/websocket.asciidoc
+++ b/doc/src/guide/websocket.asciidoc
@@ -64,6 +64,10 @@ after 1000 ->
exit(timeout)
end.
+Note that you shouldn't use the `reply_to` request option
+for connections you plan to upgrade, because only the
+owner of the connection will receive messages about it.
+
=== Sending data
Once the Websocket upgrade has completed successfully, you no