如何在Iris上使用虚拟主机?

时间:2017-03-07 12:32:17

标签: go go-iris

我想知道以下为何与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确实给了我来自其他地方的#34;,但访问example.com:3000给了我虹膜' 404页。

0 个答案:

没有答案