我想知道为什么以下内容不适用于 Iris (v6.2.0):
import (
"gopkg.in/kataras/iris.v6"
"gopkg.in/kataras/iris.v6/adaptors/httprouter"
)
func main() {
app := iris.New()
app.Adapt(iris.DevLogger())
app.Adapt(httprouter.New())
exampleCom := app.Party("example.com")
{
exampleCom.Get("/", func(c *iris.Context) {
c.Writef("hello from example.com")
})
}
app.Get("/", func(c *iris.Context) {
c.Writef("hello from everywhere else")
})
app.Listen(":3000")
}
我已在我的主机配置中将 example.com 指向 localhost。访问localhost:3000
确实给了我“来自其他地方的你好”,但访问example.com:3000
给了我 Iris 的 404 页面。