Monorepo for Tangled tangled.org

appview: initialize routers once

Signed-off-by: oppiliappan <me@oppi.li>

oppi.li 3ac788c5 6c26784d

verified
Changed files
+5 -2
appview
state
+5 -2
appview/state/router.go
··· 35 35 router.Get("/favicon.svg", s.Favicon) 36 36 router.Get("/favicon.ico", s.Favicon) 37 37 38 + userRouter := s.UserRouter(&middleware) 39 + standardRouter := s.StandardRouter(&middleware) 40 + 38 41 router.HandleFunc("/*", func(w http.ResponseWriter, r *http.Request) { 39 42 pat := chi.URLParam(r, "*") 40 43 if strings.HasPrefix(pat, "did:") || strings.HasPrefix(pat, "@") { 41 - s.UserRouter(&middleware).ServeHTTP(w, r) 44 + userRouter.ServeHTTP(w, r) 42 45 } else { 43 46 // Check if the first path element is a valid handle without '@' or a flattened DID 44 47 pathParts := strings.SplitN(pat, "/", 2) ··· 61 64 return 62 65 } 63 66 } 64 - s.StandardRouter(&middleware).ServeHTTP(w, r) 67 + standardRouter.ServeHTTP(w, r) 65 68 } 66 69 }) 67 70