extend/cowboy — pull request #395 by Egobrain (2013-02-01 18:07:48+00:00)
Title: REST: allow functions as callbacs.

Simple fix for #352 issue and partly #389.

For #352 now you can write:

```Erlang
content_types_provided(Req, State) ->
{[
{{<<"application">>, <<"json">>, []}, fun some_lib:get_json/2}
], Req, State}.
```

For #389:
```Erlang
content_type_accepted(Req, State) ->
{[
{{<<"application">>, <<"json">>, []}, wrap(fun from_json/2)},
{{<<"text">>, <<"html">>, []}, wrap(fun from_html/2)}
], Req, State}.

% Custom functions
wrapp(DecodeFun) ->
fun(Req,State) ->
case DecodeFun(Req,State) of
{true,Req2,State2} ->
process_request(Req2,State);
{false,Req2,State2} ->
{false,Req2,State2}
end
end.

process_request(Req,State) ->
...
```