[web-devel] [Yesod] When POST and create new resource
Michael Snoyman
michael at snoyman.com
Sun Nov 28 20:54:08 CET 2010
2010/11/27 Michael Snoyman <michael at snoyman.com>:
> 2010/11/27 いとうかつとし <cutsea110 at gmail.com>:
>> Hi
>> I have a question.
>> I think that, when a server receive POST request and create new
>> resource(and URI),
>> the server response is status 201, isn't it?
>> (I'm not really sure about this idea.)
>> On Yesod, How we write to make status201 response?
>
> Good catch, there is not currently a way to specify arbitrary response
> codes in Yesod. I think two API additions are in order:
>
> * respondCreated (or some better name) which sends a 201 response.
> This function should take a Route master argument.
> * sendResponseStatus, which is like sendResponse but also takes a
> Status argument (Status coming from the Network.Wai module).
For all those interested, I've just pushed a commit to the repo that
adds sendResponseStatus and sendResponseCreated. I *think* this is a
good choice in names, and I *think* it makes sense to make
sendResponseCreated its own function. However, it sort of makes sense
to include Created (and 202 Accepted) as part of the Redirect family
and just add appropriate constructors. On the other hand, they are
*not* technically redirects...
People's thoughts on this are appreciated.
Michael
More information about the web-devel
mailing list