-
Notifications
You must be signed in to change notification settings - Fork 7
Differences between PlugRest and cowboy_rest
Christopher Adams edited this page Dec 4, 2016
·
2 revisions
- Each callback accepts a Plug
conn
struct instead of a CowboyReq
record. - The
init/2
callback is not required. - The default values of
expires/2
,generate_etag/2
, andlast_modified/2
arenil
instead of:undefined
- The content callbacks (like
to_html
) return{body, conn, state}
where the body is one ofbinary()
,{:chunked, Enum.t}
, or{:file, binary()}
. - Other callbacks that need to set the body on PUT, POST, or DELETE,
can use
put_rest_body/2
taking(conn, body)
before returning it. The body can only be abinary()
. - The content types provided and accepted callbacks can describe each
media type with a String like
"text/html"
; or a tuple in the form{type, subtype, params}
, where params can be%{}
(no params acceptable),:*
(all params acceptable), or a map of acceptable params%{"level" => "1"}
. - Exceptions raised by a resource are not caught, but instead allowed to bubble up to Plug's Debugger or ErrorHandler if they are available.
-
allow_missing_post
defaults tofalse