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 scopes #10

Closed
rawleyfowler opened this issue Dec 31, 2022 · 2 comments · Fixed by #11
Closed

Add scopes #10

rawleyfowler opened this issue Dec 31, 2022 · 2 comments · Fixed by #11
Labels
enhancement New feature or request

Comments

@rawleyfowler
Copy link
Owner

Right now you have to apply middleware individually to each route. We should have some sort of scoping/grouping mechanism that injects given middleware into children route declarations.

@rawleyfowler rawleyfowler added the enhancement New feature or request label Dec 31, 2022
@rawleyfowler
Copy link
Owner Author

Here's an idea:

scope: '/location', [ &authorized ], [
    get.assuming('/location', -> $request, $response {
        $response.html('<h1>Hello World!</h1>');
    }),
    post.assuming('/location', -> $request, $response {
        $response.html('<h1>Hello World!</h1>');
    })
];

@rawleyfowler
Copy link
Owner Author

We can also omit the assuming if we make the routing subroutines return route objects, then just apply the middlewares to the objects.

@rawleyfowler rawleyfowler linked a pull request Jan 1, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant