From 6b1283d2ce0e5c36029f8e2fb8eeb3c6b7c29209 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Thu, 26 Jan 2023 11:36:00 +0100 Subject: dashboard: display subsystems in bug lists To generate filtering URLs, use the ability of context.Context to carry on variable values. --- dashboard/app/handler.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'dashboard/app/handler.go') diff --git a/dashboard/app/handler.go b/dashboard/app/handler.go index 2cb0d2739..7c6e9a23e 100644 --- a/dashboard/app/handler.go +++ b/dashboard/app/handler.go @@ -32,6 +32,7 @@ func handlerWrapper(fn contextHandler) http.Handler { func handleContext(fn contextHandler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { c := appengine.NewContext(r) + c = context.WithValue(c, currentURLKey, r.URL.RequestURI()) if err := fn(c, w, r); err != nil { hdr := commonHeaderRaw(c, r) data := &struct { @@ -73,6 +74,16 @@ func handleContext(fn contextHandler) http.Handler { }) } +const currentURLKey = "current_url" + +func getCurrentURL(c context.Context) string { + val, ok := c.Value(currentURLKey).(string) + if ok { + return val + } + return "" +} + type ( ErrClient struct{ error } ErrRedirect struct{ error } -- cgit mrf-deployment