khrt / Raisin

Raisin - a REST API micro framework for Perl 🐫 🐪
61 stars 30 forks source link

How to return 404? #30

Closed djzort closed 7 years ago

djzort commented 7 years ago

When an object/element/whatever doesnt exist, whats the proper way of returning a 404?

For example, with: curl localhost:5000/user/:id If there is no user with that ID, i would like to return a 404 - which i believe is the most correct behaviour for rest

khrt commented 7 years ago

Hi,

you can set like this:

res->status(HTTP_NOT_FOUND);

For more see https://github.com/khrt/Raisin/blob/7e87f974887a8e30b3a74a6582aff11605e6aeb3/examples/pod-synopsis-app/darth.pl#L99