Last active
August 29, 2015 14:03
-
-
Save localdisk/73c67bf2558e202c4bc4 to your computer and use it in GitHub Desktop.
CakePHP の Router::parseExtensions っぽい動きを Laravel で考えてみた
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| Route::get('api/members{ext?}', function($ext = null) | |
| { | |
| if (is_null($ext)) { | |
| $ext = 'view'; | |
| } | |
| $ext = ltrim($ext, '.'); | |
| // ここはちょっと考える必要あるかも | |
| // View の切り替えをしたい場合は View::make がいいかもしれません | |
| return Response::$ext('test'); | |
| // Response::xml を使う場合は https://gist.github.com/localdisk/8643113 | |
| // を参照してください | |
| })->where('ext', '.xml|.json'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment