[99s-extend] Cowboy Middleware and websockets

Loïc Hoguin essen at ninenines.eu
Mon May 20 15:25:53 CEST 2013


On 05/20/2013 01:53 PM, Eduardo Gurgel wrote:
>
>
>
> On Sun, May 19, 2013 at 10:01 PM, Eduardo Gurgel <edgurgel at gmail.com
> <mailto:edgurgel at gmail.com>> wrote:
>
>     I want to write a cowboy middleware that works only on non-websocket
>     requests. How can I achieve this? Is there any way that I ask the
>     Request if this is a websocket request?
>
>
> Thinking about my question, I see that the middleware (if it's behind
> the cowboy_handler) can't figure if the connection will be upgraded or not.
>
> Still, it would be cool if I could select which routes will be applied
> to my middleware.

You have the Req which can help you do things based on host or path, and 
you also have the environment, which contains the name of the handler 
that's gonna be used if you execute your middleware after cowboy_router.

-- 
Loïc Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu



More information about the Extend mailing list