Support the ongoing development of Laravel.io →
posted 10 years ago
Requests
Last updated 2 years ago.
0

Issue 1 is solved (more or less) with the following solution:

Route::group(array('domain' => 'api.example.com'), function() {
	Route::get('/', function() {
		return 'API 1';
	});
	Route::get('test', function() {
		return 'API test';
	});
	Route::any('{all}', function($uri) {
	    App::abort(404);
	})->where('all', '.*');
});

This implements a sort of catch-all route and seems to take priority over the accounts route group.

Last updated 2 years ago.
0

Issue 2 is now also solved using this solution:

//Check for identity segments
if (Request::segment(1) == 'i' and $identity = (int) Request::segment(2)) {
	//Do something with $identity
	$prefix = 'i/'.$identity;
}
else {
	$prefix = null;
}

//Wrapper for (optional) identity prefix
Route::group(array('prefix' => $prefix), function() {

	//Other route groups and routes defined here as usual
});

This way, if there is an identity parameter present, you can filter it out before the routes and set it as a prefix in a wrapper group. If no parameter is given, the prefix is null and is basically ignored.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.