lundi 2 mai 2016

Laravel routes with unlimited parameters for RESTful API

I am building a RESTful API using Laravel 5.1. The default route would be api. The user is allowed to create a url service using as many as parameters as she wants let's say .../api/p1/p2/.../pn.

How do I make a single route to point to a single Controller, so the service will be handled in a single controller?

Note : At first the application just needs to know whether the service exists or not by comparing the url with stored service in the database. As for the service itself, it can be queried into the database later.

I read that we can use * in Laravel 4, how about Laravel 5.1 ?

I have tried :

Route::resource('/api/*', 'APIServiceController'); but it does not work for unlimited parameters

or is it possible to do it like this

Route::group(['prefix' => 'api'], function () { //what should I put in the closure, how can I redirect it to a single controller });



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire