dty98339 2014-11-24 23:01
浏览 30

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

I need to set default page "index.html" located in "public" folder. How I can do this in Martini framework?

I tryed this, but it doesn't work:

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条回答 默认 最新

  • douaoj0994 2014-11-25 03:15
    关注

    You're doing it correctly. Check if you really have an index.html in public/ folder and it's accessible.

    Currently, if the fallback file is inaccessible, error is silently discarded.

    评论

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 如何将下列的“无限压缩存储器”设计出来
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口