Closed thekid closed 6 years ago
Not flexible for parameterized URLs such as /by/date/2006 or /blog/article/1345-slug.
Idea:
<<action('/')>>
class Home implements \web\handler\Action {
public function name() ==> 'home';
public function perform($req, $res) {
return [];
}
}
<<action('/page/{number}')>>
class Page implements \web\handler\Action {
public function name() ==> 'page';
public function perform($req, $res) {
return ['page' => $req->value('number')];
}
}
class Search implements \web\handler\Action {
public function name() ==> 'search';
public function perform($req, $res) {
return ['query' => $req->param('q')];
}
}
What about separating GET and POST requests?
https://fatfreeframework.com/3.6/routing-engine#ReST:RepresentationalStateTransfer
class Item {
function get() {}
function post() {}
function put() {}
function delete() {}
}
$f3=require('lib/base.php');
$f3->map('/cart/@item','Item');
$f3->run();
The Actions
class should be something castable to a Routing instance.
Usecases
/
=> Index/page/1
=> Page<1>/album/new_york
=> Album/album/new_york/IMG_1101
=> Album<new_york, IMG_1101>/collection/hopon-hopoff/bangkok
Collection<hopon-hopoff, bangkok>...with methods for CRUD:
POST /users
=> Users::create()GET /users
=> Users::list()GET /users/{id}
=> Users::get()PUT /users/{id}
=> Users::update()PATCH /users/{id}
=> Users::modify()DELETE /users/{id}
=> Users::delete()See #33 - this should be part of its own library.
Introduce the following as
web.handler.Action
implementation:Also make web.handler.Action an abstract base class, with its name method returning whatever was passed to its constructor.