jooby-project / jooby

The modular web framework for Java and Kotlin
https://jooby.io
Apache License 2.0
1.7k stars 199 forks source link

router: support for subdomains on install #3418

Closed ogrammer closed 4 months ago

ogrammer commented 5 months ago

Is it possible for a subdomain under the same domain to have different routes? It would be necessary to use the "Host" http header. Making a hidden path for each subdomain page and then writing a handler to modify the request path if "Host" is the subdomain seems like a possible solution, though I'm not sure whether it will work.

jknack commented 5 months ago

There is something: https://jooby.io/#router-dynamic-routing. That method allow you to do whatever you want before dispatching to a router.

There is one specialized version that rely on domain (Host header): https://github.com/jooby-project/jooby/blob/3.x/jooby/src/main/java/io/jooby/Router.java#L309

ogrammer commented 5 months ago

That is great thank you

ogrammer commented 5 months ago

@jknack Hi, I have just found out that there is a method install(path, supplier<jooby>). This seems very useful but it does not seem to support predicates other than path, is there a way to use that with domain?

ogrammer commented 5 months ago

I have realised that there is a discussions section, sorry for having made an issue instead.

ogrammer commented 4 months ago

@jknack?

edgar-espina-wpp commented 4 months ago

That's right: install doesn't support routing predicates. Are you sure you need install and not simply moun?