fix: some api bug

This commit is contained in:
wwweww
2026-03-31 22:12:06 +08:00
parent c5ff4f0216
commit e7970ac25f
219 changed files with 16195 additions and 2126 deletions
+23
View File
@@ -0,0 +1,23 @@
package middlewares
import (
"context"
"net/http"
)
type RequestIdMiddleware struct{}
func NewRequestMiddleware() *RequestIdMiddleware {
return &RequestIdMiddleware{}
}
func (m *RequestIdMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
requestId := r.Header.Get("X-Request-Id")
if requestId != "" {
ctx = context.WithValue(ctx, "request_id", requestId)
}
next(w, r.WithContext(ctx))
}
}