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 multiple middlewares support #51

Closed
wants to merge 1 commit into from

Conversation

antoinegomez
Copy link

This resolves #15

In some projects I need to secure some assets and I had to create a new koa instance. That's worked but I find it easier to allow to pass multiple middlewares instead of one.

Tests supplied and documentation updated.
As I work with koa@2 I did not updated the code for the stable release but it could be easily done if requested by somebody else.

@haoxins
Copy link
Member

haoxins commented Jan 16, 2017

Personally, I use koa-router for these cases.

@antoinegomez
Copy link
Author

Not thought about that way, I guess it's something like that:

router.get('/secure', isAuthedMiddleware, serve('./secure_files'));

Nonetheless I think it does not harm and could help.

@haoxins
Copy link
Member

haoxins commented Feb 6, 2017

@antoinegomez agreed, I just misunderstood something! 😢

But it's better to pass multiple middlewares as separate arguments, such as

app.use(mount('/secured', isAuthed, world))

// not

app.use(mount('/secured', [isAuthed, world]))

@haoxins
Copy link
Member

haoxins commented Feb 27, 2017

@antoinegomez I just switch next branch to master.

Please submit this PR to master.

@haoxins haoxins closed this Feb 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants