aboutsummaryrefslogtreecommitdiffstats
path: root/api/auth/middleware.go
diff options
context:
space:
mode:
Diffstat (limited to 'api/auth/middleware.go')
-rw-r--r--api/auth/middleware.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/api/auth/middleware.go b/api/auth/middleware.go
new file mode 100644
index 00000000..d1d654ce
--- /dev/null
+++ b/api/auth/middleware.go
@@ -0,0 +1,16 @@
+package auth
+
+import (
+ "net/http"
+
+ "github.com/MichaelMure/git-bug/entity"
+)
+
+func Middleware(fixedUserId entity.Id) func(http.Handler) http.Handler {
+ return func(next http.Handler) http.Handler {
+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ ctx := CtxWithUser(r.Context(), fixedUserId)
+ next.ServeHTTP(w, r.WithContext(ctx))
+ })
+ }
+}