Skip to content

Conversation

@luwake
Copy link

@luwake luwake commented Oct 17, 2017

if you sure the callable function has no param,I suggest add the $app as a param to $callable, and then you can create router like this:
`
class ApiRouter
{
public function __invoke(App $app)
{
$app->add(AuthMiddleware::class);

    $app->get('/', function (Request $request, Response $response, $args) {
        $response->getBody()->write('Hello world');
        return $response->withHeader('Content-Type', 'text/html');
    })
    ->setName('api.index');
}

}
and use it in app:
$app->group('/api', ApiRouter::class);
`

@coveralls
Copy link

Coverage Status

Coverage remained the same at 93.223% when pulling 3e0dd1b on luwake:3.x into 403b798 on slimphp:3.x.

@danopz
Copy link
Member

danopz commented Oct 17, 2017

Would you may directly backport #2229?

@akrabat
Copy link
Member

akrabat commented Oct 17, 2017

Duplicate of #2302

@akrabat akrabat marked this as a duplicate of #2302 Oct 17, 2017
@akrabat akrabat closed this Oct 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants