func construct(o *webOptions) xhandler.HandlerC { var chain xhandler.Chain chain.UseC(xhandler.CloseHandler) chain.UseC(xhandler.TimeoutHandler(o.reqTimeout)) chain.UseC(o.componentSetter) chain.UseC(o.templateCtxSetter) for _, m := range o.middlewares { chain.UseC(m) } chain.UseC(CompileInContext) chain.UseC(RenderInContext) if o.alwaysHTML { return chain.HandlerCF(WriteRenderedHTML) } return chain.HandlerCF(WriteRendered) }
func router(a *server) http.Handler { mux := xmux.New() c := xhandler.Chain{} c.Use(mwLogger) c.Use(mwAuthenticationCheck(a.key)) mux.GET("/sites", c.HandlerCF(xhandler.HandlerFuncC(a.handleAllSites))) mux.GET("/sites/:id", c.HandlerCF(xhandler.HandlerFuncC(a.handleSingleSite))) mux.GET("/torrents", c.HandlerCF(xhandler.HandlerFuncC(a.handleTorrents))) mux.POST("/download/:hash", c.HandlerCF(xhandler.HandlerFuncC(a.handleDownload))) return xhandler.New(context.Background(), mux) }