diff options
author | Loïc Hoguin <[email protected]> | 2013-01-18 00:15:00 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2013-01-18 00:15:00 +0100 |
commit | acd89f61161820a0acde354e3cbd8da1600d0aa4 (patch) | |
tree | efca18daaaf69b1ba059214ed9af791a6ee05506 /guide/handlers.md | |
parent | 1f1969ba7123c2dc4af8b0391104d3147dfe3c3a (diff) | |
download | cowboy-acd89f61161820a0acde354e3cbd8da1600d0aa4.tar.gz cowboy-acd89f61161820a0acde354e3cbd8da1600d0aa4.tar.bz2 cowboy-acd89f61161820a0acde354e3cbd8da1600d0aa4.zip |
Explain how to write custom protocol upgrades in the guide
Diffstat (limited to 'guide/handlers.md')
-rw-r--r-- | guide/handlers.md | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/guide/handlers.md b/guide/handlers.md index dac5460..e2c1264 100644 --- a/guide/handlers.md +++ b/guide/handlers.md @@ -33,7 +33,23 @@ init(_Any, _Req, _Opts) -> {upgrade, protocol, my_protocol}. ``` -The `my_protocol` module will be used for further processing of the -request. It requires only one callback, `upgrade/4`. +Cowboy comes with two protocol upgrades: `cowboy_rest` and +`cowboy_websocket`. Use these values in place of `my_protocol` +to use them. -@todo Describe `upgrade/4` when the middleware code gets pushed. +Custom protocol upgrades +------------------------ + +The `my_protocol` module above will be used for further processing +of the request. It requires only one callback, `upgrade/4`. + +It receives the request object, the middleware environment, and +the handler this request has been routed to along with its options. + +``` erlang +upgrade(Req, Env, Handler, HandlerOpts) -> + %% ... +``` + +This callback is expected to behave like any middleware. Please +see the corresponding chapter for more information. |