dtlrp119999 2017-03-07 12:32
浏览 68

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

I'm wondering why the following won't work with 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")
}

I have pointed example.com to localhost in my hosts configuration. Visiting localhost:3000 does give me "hello from everywhere else", but visiting example.com:3000 gives me Iris' 404 page.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 一道python难题2
    • ¥15 一道python难题
    • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler
    • ¥15 oracle集群安装出bug
    • ¥15 关于#python#的问题:自动化测试
    • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
    • ¥15 教务系统账号被盗号如何追溯设备