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

Adds middleware to the same Layer as the renderer #680

Closed
wants to merge 1 commit into from

Conversation

felkerch
Copy link
Contributor

@felkerch felkerch commented Nov 7, 2019

Amphora currently attaches route-specific middleware by adding two Layers to the router: one for the middleware and then one for the renderer. This PR adds them to the same layer. Basically this is the diff:

- router.use(path, middleware);
- router.get(path, renderer);
+ router.get(path, [middleware, renderer]);

You'll see different behavior if your middleware makes changes to the request (we change the URL for pagination).

The interface for adding routes to a site remains the same:

module.exports.routes = [
    { path: "/:name", middleware: [fn] },
    ...
]

@coveralls
Copy link

coveralls commented Nov 7, 2019

Pull Request Test Coverage Report for Build 2428

  • 20 of 20 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 2426: 0.0%
Covered Lines: 4178
Relevant Lines: 4178

💛 - Coveralls

```diff
- router.use(path, middleware);
- router.get(path, renderer);
+ router.get(path, [middleware, renderer]);
```
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.

2 participants