本文整理汇总了Golang中github.com/Unknwon/macaron.Macaron.Use方法的典型用法代码示例。如果您正苦于以下问题:Golang Macaron.Use方法的具体用法?Golang Macaron.Use怎么用?Golang Macaron.Use使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/Unknwon/macaron.Macaron
的用法示例。
在下文中一共展示了Macaron.Use方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: InitRoutes
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)
}
示例2: mapStatic
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,
},
))
}
示例3: SetMiddlewares
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())
}
示例4: SetMiddlewares
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())
}
示例5: SetMiddlewares
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())
}
示例6: SetMiddlewares
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())
}