本文整理匯總了Golang中github.com/mholt/caddy/middleware/browse.Browse類的典型用法代碼示例。如果您正苦於以下問題:Golang Browse類的具體用法?Golang Browse怎麽用?Golang Browse使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Browse類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GET
// GET handles the GET method on browse page
func GET(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error) {
functions := template.FuncMap{
"CanBeEdited": utils.CanBeEdited,
"Defined": utils.Defined,
}
tpl, err := utils.GetTemplate(r, functions, "browse")
if err != nil {
return http.StatusInternalServerError, err
}
b := browse.Browse{
Next: middleware.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) {
return 404, nil
}),
Root: c.Path,
Configs: []browse.Config{
{
PathScope: "/",
Variables: c,
Template: tpl,
},
},
IgnoreIndexes: true,
}
return b.ServeHTTP(w, r)
}
示例2: Browse
// Browse configures a new Browse middleware instance.
func Browse(c *Controller) (middleware.Middleware, error) {
configs, err := browseParse(c)
if err != nil {
return nil, err
}
browse := browse.Browse{
Configs: configs,
IgnoreIndexes: false,
}
return func(next middleware.Handler) middleware.Handler {
browse.Next = next
return browse
}, nil
}
示例3: Browse
// Browse configures a new Browse middleware instance.
func Browse(c *Controller) (middleware.Middleware, error) {
configs, err := browseParse(c)
if err != nil {
return nil, err
}
browse := browse.Browse{
Root: c.Root,
Configs: configs,
}
return func(next middleware.Handler) middleware.Handler {
browse.Next = next
return browse
}, nil
}