From 3ac788c523c1732b671db7fa53d45d28cfea725d Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Tue, 19 Aug 2025 16:12:33 +0100 Subject: [PATCH] appview: initialize routers once Signed-off-by: oppiliappan --- appview/state/router.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/appview/state/router.go b/appview/state/router.go index cfb5e8cf..dcdf2b6b 100644 --- a/appview/state/router.go +++ b/appview/state/router.go @@ -35,10 +35,13 @@ func (s *State) Router() http.Handler { router.Get("/favicon.svg", s.Favicon) router.Get("/favicon.ico", s.Favicon) + userRouter := s.UserRouter(&middleware) + standardRouter := s.StandardRouter(&middleware) + router.HandleFunc("/*", func(w http.ResponseWriter, r *http.Request) { pat := chi.URLParam(r, "*") if strings.HasPrefix(pat, "did:") || strings.HasPrefix(pat, "@") { - s.UserRouter(&middleware).ServeHTTP(w, r) + userRouter.ServeHTTP(w, r) } else { // Check if the first path element is a valid handle without '@' or a flattened DID pathParts := strings.SplitN(pat, "/", 2) @@ -61,7 +64,7 @@ func (s *State) Router() http.Handler { return } } - s.StandardRouter(&middleware).ServeHTTP(w, r) + standardRouter.ServeHTTP(w, r) } }) -- 2.51.2