Fork me on GitHub

I'd like to set up different routers for different subdomains (specifically, I want to proxy all traffic to another service for certain values of the Host header) — how can I do make this happen?


Sounds like middleware can be used here which will look into Host header.


Hmm yeah I was thinking something like that might work — although, doesn't Retit match routes before calling the middleware stack?

wombawomba12:10:53 seems to me like if I go with that approach, I'd have to allow conflicting routes, and create a 'base' route that matches everything — but only does something when the Host header has the appropriate value — and in that case, there's no point in adding that middleware, right?


Wait, scratch that. I get it, I need the middleware.


Yeah just wrap a new middleware around the existing handler and middleware always has the option to process before/after existing handler.