aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_http_rest.erl
AgeCommit message (Collapse)Author
2011-12-05Add experimental Webmachine based REST protocol supportLoïc Hoguin
As with everything experimental, it probably has a lot of bugs and may not even work. Like Websocket, REST must be upgraded from a standard resource through the init/3 function. A key difference between Webmachine and Cowboy's REST protocol handler is that in Cowboy the resource has direct access to the request object. This makes a small change in a few places where you were expected to return headers or body in Webmachine and are now expected to set them directly yourself if needed (options/2, for example). Another difference is that the functions rest_init/2 will always be called when starting to process a request. Similarly, rest_terminate/2 will be called when the process completes successfully. The Cowboy REST support also includes automatic language selection, thanks to the languages_provided/2 callback. Finally, Cowboy REST expects full URIs to be given at all times, and will not try to reconstruct URIs from fragments. Note that REST requests cannot be chained (keepalive) at this time. This is a design issue in cowboy_http_protocol that will be fixed soon. Check out the source for more details. It has been designed to be very easy to read and understand so if you don't understand something, it's probably a bug. Thanks in advance for all the great bug reports, pull requests and comments you'll forward my way!