Serving different Page based on incoming URL

Hello,

I am looking for a way to serve pages based on the incoming URL.

For example, if there are two domains (say abc1.com and abc2.com) pointing to the same Go lang web app running at same port, then how can I serve two different pages? I want to use same port not multiple ports.

I thought about Middlewares but I am bit confused how to use them.

Any help/guidance would be nice.

Thanks in advance.

http.Request has a Host field that contains the domain used in the request. Use that in a handler to switch to the specific site handler.

If you are using a third-party router such as Gorilla mux, you can configure routes that include host names.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.