Comments (6)
This is great! As far as I understand, now I can
match "/api-call", via: :post, host: "api."
right? This is a great first step in supporting host-based routing. If I learn enough Elixir to come up with an elegant solution for at least forward
ing routes to other plugs based on the domain I'll open a PR.
Again, thank you so much. Elixir is a wonderful language, but it's thanks to the attitude of people like you that I can easily imagine a brilliant future for it. And I'm looking forward to being a part of it 😃
from plug.
I think we could indeed support the host option. But we don't have scope, so you would either have to forward it or repeat it everywhere, but definitely doable!
from plug.
Yes, scope
is the perfect context for this feature since it allows to define a group of routes under the same conditions --- in this case, the subdomain. Forwarding to another plug could be a great start in my opinion: something like
forward "*", host: "api.", to: AnotherPlug
allows for a clean syntax and encourages modularity. I don't think this is a permanent solution since one could need to dynamically dispatch based on the subdomain (e.g. [username].github.io
), but it's a start!
I still don't have the Elixir skills I think are necessary for adding this feature to Plug, but I'd be happy to help in any other way!
from plug.
Done in a9eba75.
I got curious how this would work with Plug, as I would have to refactor some bits first, but it was easier than expected. :D
from plug.
Forwarding works too. Maybe I should have updated its docs too? There are
tests though. :)
José Valimwww.plataformatec.com.br
http://www.plataformatec.com.br/Founder and Lead Developer
from plug.
Well, great! I'll open a PR with some updated docs as soon as I can then :)
from plug.
Related Issues (20)
- Mismatch spec for `Plug.Conn.Query.decode` HOT 1
- Plug.RequestId: put the `request_id` in `:private` or `:assigns`? HOT 1
- 1.15 changes decoding behaviour of `[]` HOT 5
- Request: Support MFA tuple for Plug.Session opts HOT 4
- Plug.Upload's random-tempdir generation is not very random HOT 1
- `strip_spaces` fails on `nil` since 1.15.0 HOT 1
- Plug.Conn.Query has changed the way it decodes parameters from 1.14 to 1.15 without warning HOT 1
- More flexible dynamic routes with `:` parameters HOT 2
- Compatibility issue with plug_crypto 2.0.0 HOT 3
- Error: There isn't enough space to open the popup HOT 1
- Docs inconsistency between Plug moduledoc and Plug.run HOT 1
- Plug.Upload: demonitor previous owner when giving away HOT 1
- Compilation issues on Erlang 26.x HOT 3
- html array items are dropped. HOT 1
- Plug.Conn is not closed when user closes the browser's tab (SSE) HOT 2
- setting max_age to nil in put_resp_cookie/4 causes crash HOT 1
- Sending a zip created on-the-fly via Plug.Conn.chunk fails after around 200Mb HOT 8
- Performance Regression in Plug.Conn.Cookies.decode/1 after Upgrading Elixir and Erlang HOT 3
- Plug.Router macros and functional plugs HOT 2
- Wrong editor links when running inside a container HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plug.