-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Route for subdomains #1342
Comments
After #1301 it's possible to register subapplications by prefix. I suggest the same technique but for resolving by subdomain. |
I am currently using the approach of adding a custom middleware which specifically filters out unknown hostnames, the only issue I am currently having is that it quite hard to support real micro-services with different domains, but this isn't an issue anymore especially after @asvetlov has landed sub-applications :). |
I mean we could add a method |
@asvetlov Do you also consider supporting wildcards in the domain name as well a falback so unknown domains are handled too? |
Why not? |
@asvetlov Well, by looking at your example I thought you would like to keep it very simple, so in that case I assumed it would come without wildcard and fallback domain support. But yeah, it's good to know that you will include that too :). |
Is it implemented? |
no, it is not |
Very sad :( |
Would you provide PR? |
Nah, I'm not familiar with aiohttp |
@TiberiumPY I did not wait for decisions, so switched to another framework |
@alikzao what framework? |
You have plenty of options. Pyramid, flask. |
If this has not been done yet, I'd like to have add_domain instead of add_subdomain. It would be a nice feature which could easily enable multi-site support for aiohttp applications. Further, having remove_subapp() and remove_domain() would complete the feature allowing to dinamically add and remove features to a website and in my opinion could be a nice thing to have (paid features come to mind but also a multi-site cms where user can actually load the features they want could be handled this way easily). |
I suggest to rewrite domain to prefix on front web-server (like nginx) |
@alex-eri it doesn't work well outside production, except if you also have to configure nginx on the development host. |
I am willing to work on this.
And prolly:
|
Sorry, I don't follow |
Sorry, please forget about the eoe thing. |
Hi there, I'd like to ask you if you going to add this feature to the aiohttp official release at all? I'm asking because the corresponding pull request seems to be abandoned by an author. And second question. Why don't you want to add an ordinary routing by the 'Host' header to aiohttp, like it is available almost in all modern web framework (e.g. tornado, sanic)? Like this: I could provide an appropriate pull request. |
Currently nobody works on the feature AFAIK but we very appreciate the contribution. Regarding to second question ( |
Sorry, but I don't get it, what do you mean writing that 'the code mixes routing by host and bare requests'? I don't like the concept with sub-apps in this case because I'll have to create sub-apps to use the routing by host feature. Whereas sub-apps in aiohttp are for solving problem with big projects, not for routing purposes. |
Now in aiohttp router is conceptually a table of regular expressions (let's assume that I prefer to have a route table per host. |
Ok, thanks for clarifying. So it means that futher developing an implementation of routing by host proposed by me doesn't make any sense :) |
But explicit domain/subdomain support does make sense :) |
It's probably a little tricky, but route and subdomain rules can be combined in a single regular expression. I believe werkzeug does this. |
I pretty sure the combining is an implementation artifact, not the main intention. |
I believe this should have been closed by #2809 |
Describe
Sometimes there are situations when it is necessary for the current project to create a subdomain just as another rout.
And hang on to this subdomain a handler that is already there.
Expected behaviour
For example it might look something like this:
The text was updated successfully, but these errors were encountered: