Usbac/wolff

Where is API feature in the Routes System?

Closed this issue · 1 comments

There used to be a Route::api() in previous versions which was really useful to communicate with other external services.
My question is how do we use this functionality in the recent version? and if possible can you add it to the documentation http://getwolff.com/doc/3.x/routes

Also, I really like the Container feature mentioned in the documentation https://getwolff.com/doc/3.x/container which can enable us write our own custom Classes/Libraries.
The documentation is however not explicit...like where do we store these custom class, how to call it from a controller file, etc.

Thank you

Usbac commented

Hello @siteantipas! I'm sorry for the late response.

The equivalent of the Route::api() method in the 3.x version looks like this:

Route::any('json:your_page', function ($req, $res) {
    // Code
});

The old api method is just a route that works for any HTTP method and has the Content-Type header set to application/json.

About the Container feature, since it is static you can add elements to the Container and get them anywhere inside Wolff, but I'll take your recommendation about the documentation and update it and soon as I can.

Regards! :)