如何在Martini中设置默认静态页面?

时间:2014-11-24 23:01:57

标签: go martini

我需要设置默认页面" index.html"位于" public"夹。我如何在Martini框架中做到这一点?

我试过这个,但它不起作用:

func main() {
    m := martini.Classic()
    static := martini.Static("public", martini.StaticOptions{Fallback: "/index.html", Exclude: "/send"})
    m.NotFound(static, http.NotFound)
    m.Use(static)
    m.Get("/send", sendEmail)
    m.Run()
}

1 个答案:

答案 0 :(得分:0)

你正确地做到了。检查 public / 文件夹中是否确实有 index.html ,并且可以访问它。

目前,如果无法访问后备文件,则会以静默方式丢弃错误。

相关问题