Git Product home page Git Product logo

Comments (6)

whatyouhide avatar whatyouhide commented on September 23, 2024 1

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 forwarding 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.

josevalim avatar josevalim commented on September 23, 2024

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.

whatyouhide avatar whatyouhide commented on September 23, 2024

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.

josevalim avatar josevalim commented on September 23, 2024

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.

josevalim avatar josevalim commented on September 23, 2024

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.

whatyouhide avatar whatyouhide commented on September 23, 2024

Well, great! I'll open a PR with some updated docs as soon as I can then :)

from plug.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.