Use of REST to application

39 views
Skip to first unread message

Marlysson Silva

unread,
Jun 24, 2016, 6:53:52 AM6/24/16
to web2py-users
Good morning.

Folks, the use of decorator @request.restful() already it's enough to building the rest api?

Already cover all the possibilities?

Anthony

unread,
Jun 24, 2016, 8:42:46 AM6/24/16
to web2py-users
@request.restful is just a very simple convenience decorator that allows you to write a controller action in a particular format that makes it easy to handle different request methods (i.e., get, post, put, delete). It would be fairly easy to write a similar controller action without using the decorator (you would just have to use some if/elif blocks to separately handle different request types based on request.env.request_method). So, in that sense, I suppose it "covers all the possibilities," but that's not saying much, as the code you write in the controller is what really makes up the API.

The more powerful features with regard to API generation are parse_as_rest and smart_query, which make it easier for you to generate a consistent REST API for access to database tables.

Anthony
Reply all
Reply to author
Forward
0 new messages