Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add route group #239

Closed
wants to merge 1 commit into from
Closed

add route group #239

wants to merge 1 commit into from

Conversation

wpjscc
Copy link

@wpjscc wpjscc commented Oct 18, 2023

can use addGroup

       $app->addGroup('/users', [
            // middleware1,
            // middleware2
        ], function ($app) {
            $app->get('/{name}', function ($request) {
                return \React\Http\Message\Response::plaintext(
                    "Hello " . $request->getAttribute('name') . "!\n"
                );
            });
            $app->addGroup('/{name}/posts', [
                // middleware1,
                // middleware2
            ], function ($app) {
                $app->get('/{post}', function ($request) {
                    return \React\Http\Message\Response::plaintext(
                        "Hello User {$request->getAttribute('name')} Posts " . $request->getAttribute('post') . "!\n"
                    );
                });
            });
        });

        $app->addGroup('/posts', [
            // middleware1,
            // middleware2
        ], function ($app) {
            $app->get('/{post}', function ($request) {
                return \React\Http\Message\Response::plaintext(
                    "Hello Posts " . $request->getAttribute('post') . "!\n"
                );
            });
        });

@wpjscc wpjscc closed this Oct 18, 2023
@SimonFrings SimonFrings added the invalid This doesn't seem right label Oct 18, 2023
@SimonFrings
Copy link
Contributor

Follow up pull request in #241.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants