Last active
August 29, 2015 14:18
-
-
Save edvakf/413267d9639c5950ed65 to your computer and use it in GitHub Desktop.
フレームワークではなくライブラリとして使うPHPのルーター案
This file contains 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 | |
if ($m = RT::get('/works/:id' /*pathパターン*/, [':id:uint' /*pathのパラメータ*/])) { | |
getWorks($m[':id']); | |
} else if ($m = RT::get('/works/', ['page:uint:1' /*GETパラメータ。デフォルト1*/, 'type:string:' /*GETパラメータ。デフォルト空文字*/, 'tags:string[]' /*GETパラメータ。配列のみ受け取る。デフォルトは空配列?*/])) { | |
getWorks($m['page'], $m['type'], $m['tags']); | |
} elseif ($m = RT::post('/works/', [] /*pathパラメータとGETパラメータは処理しない*/, ['type:string'] /*POSTパラメータ*/)) { | |
postWork($m['type']); | |
} else { | |
// not found | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment