diff --git a/serve.go b/serve.go index 9136679..abb0d9b 100644 --- a/serve.go +++ b/serve.go @@ -77,6 +77,21 @@ func serve(c *cli.Context) error { return err } + // Setting template renderer + re := multitemplate.NewRenderer() + + // Setting Helper + helper := w.NewHelper(c) + + // Setting Helper + umamiHelper := umami.NewHelper(c) + + // Setting TemplateManager + tm := template.NewManager(re). + WithHelper(helper). + WithHelper(umamiHelper). + WithContextWrapper(w.NewContext) + var servers []cs.Servable // Setting Probe probe := cs.NewProbe(c) @@ -91,10 +106,6 @@ func serve(c *cli.Context) error { servers = append(servers, pprof) defer pprof.Close() } - - // Setting template renderer - re := multitemplate.NewRenderer() - // Setting Gin r := gin.Default() r.HTMLRender = re @@ -112,13 +123,28 @@ func serve(c *cli.Context) error { return err } - err = sta.RegisterHandler(c, r) - if err != nil { - return err + // Setting Auth + a := auth.New(c) + + if a != nil { + err := a.Init() + if err != nil { + return err + } + a.RegisterHandler(r) + wau.RegisterHandler(r, tm) } - // Setting Migration from v1 to v2 - wm.RegisterHandler(r) + // Setting Claims Client + cpCl := claims.NewClient(c) + defer cpCl.Close() + + // Setting UserClaims + uc := claims.New(c, cpCl) + if uc != nil { + // Setting UserClaimsHandler + uc.RegisterHandler(r) + } // Setting HTTP Client cl := http.DefaultClient @@ -126,17 +152,16 @@ func serve(c *cli.Context) error { // Setting Api sapi := api.New(c, cl) - // Setting Helper - helper := w.NewHelper(c) + // Setting ApiClaimsHandler + sapi.RegisterHandler(r) - // Setting Helper - umamiHelper := umami.NewHelper(c) + err = sta.RegisterHandler(c, r) + if err != nil { + return err + } - // Setting TemplateManager - tm := template.NewManager(re). - WithHelper(helper). - WithHelper(umamiHelper). - WithContextWrapper(w.NewContext) + // Setting Migration from v1 to v2 + wm.RegisterHandler(r) // Setting Redis redis := cs.NewRedisClient(c) @@ -150,18 +175,6 @@ func serve(c *cli.Context) error { jobs.RegisterHandler(r) - // Setting Auth - a := auth.New(c) - - if a != nil { - err := a.Init() - if err != nil { - return err - } - a.RegisterHandler(r) - wau.RegisterHandler(r, tm) - } - // Setting AbuseStore asc := as.New(c) @@ -174,23 +187,9 @@ func serve(c *cli.Context) error { legal.RegisterHandler(r, tm) } - // Setting Claims Client - cpCl := claims.NewClient(c) - defer cpCl.Close() - - // Setting UserClaims - uc := claims.New(c, cpCl) - if uc != nil { - // Setting UserClaimsHandler - uc.RegisterHandler(r) - } - // Setting DomainSettings ds := embed.NewDomainSettings(pg, uc) - // Setting ApiClaimsHandler - sapi.RegisterHandler(r) - // Setting ResourceHandler wr.RegisterHandler(r, tm, sapi, jobs) diff --git a/templates/views/action/download_file.html b/templates/views/action/download_file.html index 095cb7f..041faee 100644 --- a/templates/views/action/download_file.html +++ b/templates/views/action/download_file.html @@ -4,7 +4,18 @@ var file = new URL(url).pathname.split('/').pop(); var wgetCmd = `wget -c -O "${file}" -t 20 "${url}"`; -
Your current download speed will be limited to {{ .Claims.Claims.Connection.Rate }}Mbps, donate to increase your speed and remove ads!
+ {{- end }}
+