brendanmetzger / diatom

A template framework
1 stars 0 forks source link

Controllers can return controllers #67

Open brendanmetzger opened 3 years ago

brendanmetzger commented 3 years ago

This would allow a controller to proxy another controller, notably in the instance of a http controller running a command line controller, but would be liberal in the interface it applies. something of the nature:


public function GETexample() {

  return Command::task('args...')->apply($this->response);

}

This would have some effect of adding a controller to the chain (currently only possible with simple route callbacks., eg.,


Route::set('endpoint', fn($args) => 'result')->then(fn($result) => 'new result');

would apply to controllers that return controllers, and then the list of commands could be executed during the delegation of the route. This would allow controllers themselves to allow a greater degree of opportunity, such as returning a different controller depending on the input, which may be especially useful for protected methods that have differing roles depending on which user made the request