1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

fix: badges broken (resolve #475)

This commit is contained in:
Ferdinand Mütsch
2023-03-15 21:47:12 +01:00
parent 46a248ac30
commit c9f2518fbc
13 changed files with 240 additions and 53 deletions

View File

@@ -0,0 +1,17 @@
package api
import (
"context"
"github.com/go-chi/chi/v5"
"net/http"
"strings"
)
func withUrlParam(r *http.Request, key, value string) *http.Request {
r.URL.RawPath = strings.Replace(r.URL.RawPath, "{"+key+"}", value, 1)
r.URL.Path = strings.Replace(r.URL.Path, "{"+key+"}", value, 1)
rctx := chi.NewRouteContext()
rctx.URLParams.Add(key, value)
r = r.WithContext(context.WithValue(r.Context(), chi.RouteCtxKey, rctx))
return r
}