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

Allow set router host match #121

Closed
wants to merge 1 commit into from
Closed

Allow set router host match #121

wants to merge 1 commit into from

Conversation

yeliex
Copy link
Contributor

@yeliex yeliex commented Jun 18, 2021

const router = new Router({
    host: 'example.domain' // host === 'example.domain'
});

OR

const router = new Router({
    host: /.*\.example\.domain$/
});

Just for discussion currently, more test case would complete

@etroynov
Copy link
Contributor

@yeliex in what cases it can be useful?

@titanism
Copy link
Contributor

titanism commented Jul 4, 2022

Closing, if you want to re-open a new PR with resolved conflicts and possibly add a few examples to README then ping us!

@titanism titanism closed this Jul 4, 2022
@titanism
Copy link
Contributor

titanism commented Jul 4, 2022

We have just published @koajs/router v11.0.0 which resolves this issue. This is mirrored to koa-router as well.

https://github.com/koajs/router/releases/tag/v11.0.0

This project is maintained by Forward Email and Lad.

@yeliex
Copy link
Contributor Author

yeliex commented Jul 4, 2022

@titanism @etroynov sorry for the late response. (never image the repo would be re-active)

as PR describes, it is for a server with many hosts, and the same path in each host may different.

for example

const routerA = new Router({
    host: 'a.domain'
});

routerA.get('/', () => {}) // return page for http://a.domain

const routerB = new Router({
    host: 'b.domain'
});

routerB.get('/', () => {}) // return page for http://b.domain

if want to do this in current version, we should detect the host in controller function.

@titanism
Copy link
Contributor

titanism commented Jul 4, 2022

Thank you - just submit a new PR if you'd like! 🙇

@yeliex
Copy link
Contributor Author

yeliex commented Jul 4, 2022

#156

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.

3 participants