I'm using laravel to make an API. The following endpoints will be available:
Currently I have:
Route::get('/{appname}/{network}/{device}', function()
{
return 'Hello World';
});
This services /appname/network/device/ but what I would like is so it can be the following but in one route without the need for additional routing:
Route::get('/{appname}', function()
{
return 'App Name';
});
Route::get('/{appname}/{network}', function()
{
return 'App Name / Network';
});
Route::get('/{appname}/{network}/{device}', function()
{
return 'App Name / Network / Device';
});
I understand that I could use RESTFUL controllers but this would only work (I believe) with names like:
public function getAppname()
{
//app
}
But if I used:
public function getAppnameNetwork()
{
//app-network
}
it would become:
/appname-network/
Any advice/help would be greatly appreciated.
Thanks :)