Skip to content

Directly call cowboy REST handler inside app #1642

Answered by essen
bever1337 asked this question in Q&A
Discussion options

You must be logged in to vote

There currently isn't. Part of the reason is that REST handlers are still very closely tied to HTTP, whereas to do what you want it would be more appropriate to have protocol-generic resource. This is what I've been experimenting on in https://github.com/ninenines/farwest but it is incomplete. Some parts of this experimentation will make it into Cowboy 3.0 (new router, at the very least, so that we can find the resources).

As it currently stands, you probably should run the handler in a separate process, since cowboy_rest will send the response as a message. So what you need to use is cowboy_stream and let Cowboy handle it from there. Then your own code needs to respond to messages and pr…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by bever1337
Comment options

You must be logged in to vote
1 reply
@essen
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants