-
Howdy! Is there a way to directly execute a REST handler? For example,a REST service uses hypermedia with linking, ex JSON HAL. When a response links to another resource, the server optionally embeds that second resource into the first response. I would like to use a middleware approach, but I'm not sure how to wait for the resolution of additional requests without using HTTP (or whatever protocol that cowboy+handler is configured to use). Alternatively, I know handler Thank y'all for the consideration |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
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 |
Beta Was this translation helpful? Give feedback.
-
Thank you very much for the prompt reply. This is a huge help. |
Beta Was this translation helpful? Give feedback.
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 iscowboy_stream
and let Cowboy handle it from there. Then your own code needs to respond to messages and pr…