func InitRoutes(m *macaron.Macaron, adminKey string) { m.Use(GetContextHandler()) m.Use(Auth(adminKey)) m.Get("/", index) m.Post("/metrics", Metrics) m.Post("/events", Events) m.Any("/graphite/*", GraphiteProxy) m.Any("/elasticsearch/*", ElasticsearchProxy) }
func mapStatic(m *macaron.Macaron, dir string, prefix string) { headers := func(c *macaron.Context) { c.Resp.Header().Set("Cache-Control", "public, max-age=3600") } if setting.Env == setting.DEV { headers = func(c *macaron.Context) { c.Resp.Header().Set("Cache-Control", "max-age=0, must-revalidate, no-cache") } } m.Use(httpstatic.Static( path.Join(setting.StaticRootPath, dir), httpstatic.StaticOptions{ SkipLogging: true, Prefix: prefix, AddHeaders: headers, }, )) }
func SetMiddlewares(m *macaron.Macaron) { m.Use(macaron.Static("static", macaron.StaticOptions{ Expires: func() string { return "max-age=0" }, })) m.Map(Log) m.Use(logger()) m.Use(macaron.Recovery()) }
func SetMiddlewares(m *macaron.Macaron) { m.Use(macaron.Static("static", macaron.StaticOptions{ Expires: func() string { return "max-age=0" }, })) InitLog(setting.RunMode, setting.LogPath) m.Map(Log) m.Use(logger(setting.RunMode)) m.Use(macaron.Recovery()) }
func SetMiddlewares(m *macaron.Macaron) { //Set static file directory,static file access without log output m.Use(macaron.Static("external", macaron.StaticOptions{ Expires: func() string { return "max-age=0" }, })) InitLog(setting.RunMode, setting.LogPath) //Set global Logger m.Map(Log) //Set logger handler function, deal with all the Request log output m.Use(logger(setting.RunMode)) //Set the response header info m.Use(setRespHeaders()) //Set recovery handler to returns a middleware that recovers from any panics m.Use(macaron.Recovery()) }
func SetMiddlewares(m *macaron.Macaron) { m.Use(macaron.Static("external", macaron.StaticOptions{ Expires: func() string { return "max-age=0" }, })) m.Map(Log) m.Use(logger(setting.RunMode)) //modify default template setting m.Use(macaron.Renderer(macaron.RenderOptions{ Directory: "views", Extensions: []string{".tmpl", ".html"}, Funcs: []template.FuncMap{}, Delims: macaron.Delims{"<<<", ">>>"}, Charset: "UTF-8", IndentJSON: true, IndentXML: true, PrefixXML: []byte("macaron"), HTMLContentType: "text/html", })) m.Use(macaron.Recovery()) }
func SetMiddlewares(m *macaron.Macaron) { //设置静态文件目录,静态文件的访问不进行日志输出 m.Use(macaron.Static("static", macaron.StaticOptions{ Expires: func() string { return "max-age=0" }, })) //设置全局 Logger m.Map(Log) //设置 logger 的 Handler 函数,处理所有 Request 的日志输出 m.Use(logger()) //设置 panic 的 Recovery m.Use(macaron.Recovery()) }