jjzjj

basicAuthHandler

全部标签

go - 使用 Alice 和 HttpRouter 的中间件

我似乎不知道如何正确地一起使用中间件和HttpRouter。我的代码是:typeappContextstruct{db*mgo.Database}funcmain(){c:=appContext{session.DB("db-name")}commonHandlers:=alice.New(context.ClearHandler,basicAuthHandler)router:=NewRouter()router.Post("/",commonHandlers.ThenFunc(c.final))http.ListenAndServe(":5000",router)}最终中间件是:f