Handling subdomains
dgrr opened this issue · comments
Darío commented
How this library can handle subdomains like cloud.dmester.xyz or similar?
Or directly domains like dmester.xyz or librelabua.org in the same program without needing reverse proxy or similar.
Erik Dubbelboer commented
Something like this:
func main() {
clouddmesterxyz := fasthttprouter.New()
clouddmesterxyz.GET("/", clouddmesterxyzIndex)
dmesterxyz := fasthttprouter.New()
dmesterxyz.GET("/", dmesterxyzIndex)
clouddmesterxyzHost := []byte("cloud.dmester.xyz")
log.Fatal(fasthttp.ListenAndServe(":8080", func(ctx *fasthttp.RequestCtx) {
if bytes.Equal(ctx.Host(), clouddmesterxyzHost) {
clouddmesterxyz.Handler(ctx)
} else {
dmesterxyz.Handler(ctx)
}
})
}