Skip to content
This repository has been archived by the owner on Dec 11, 2018. It is now read-only.

Commit

Permalink
explain how to pass options to your own handler.
Browse files Browse the repository at this point in the history
it wasn't clear where the user's handler options should go, after looking at the code and trying this is what I've found, correct me if there's a better way.
  • Loading branch information
marianoguerra committed Aug 29, 2014
1 parent 999f02f commit 04a6efe
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ The dispatch options for a Bullet handler looks as follow:
Simply define this in your dispatch list and your handler will be
available and handled by Bullet properly.

The third element in the tuple ([{handler, my_stream}]) will be passed
to init/4 as Opts, you can add your own options and get them using
lists:keyfind, for example if we define our handler as:

``` erlang
{[<<"path">>, <<"to">>, <<"bullet">>], bullet_handler,
[{handler, my_stream}, {channel, "my channel"}]}
```

you can retrieve the channel value as follows:

``` erlang
init(_Transport, Req, Opts, _Active) ->
{channel, Channel} = lists:keyfind(channel, 1, Opts),
{ok, Req, #state{channel=Channel}}.
```

Cowboy handler
--------------

Expand Down

0 comments on commit 04a6efe

Please sign in to comment.