[99s-extend] cowboy_rest and delete_completed and response

Loïc Hoguin essen at ninenines.eu
Wed Aug 27 00:03:45 CEST 2014


Call cowboy_req:meta(media_type, Req) to retrieve it.

On 08/27/2014 12:59 AM, Stéphane Wirtel wrote:
> Hi all,
>
> I work with two content-types (json, msgpack).
>
> In the DELETE verb, I need to return an object and in this case, I work
> on delete_resource/2 and delete_completed/2.
> The problem is, how can I return a body in function of the content-type?
> because after delete_completed, there is a call to the
> cowboy_rest:has_resp_body function and I need to set the body of the
> response.
>
> delete_completed(Req, State) ->
>      Body = Json or MsgPack ?  <-- Which content ?
>
>      Req2 = cowboy_req:set_resp_body(Body, Req),
>      {true, Req2, State}.
>
> Ok, but in this case, what's the reason of content_types_provided/2 and
> content_types_accepted/2 ?
>
> Thank you,
>
> Stephane
>
>
> --
> Stéphane Wirtel - http://wirtel.be - @matrixise
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> https://lists.ninenines.eu/listinfo/extend

-- 
Loïc Hoguin
http://ninenines.eu


More information about the Extend mailing list