This commit is contained in:
Mrx
2026-05-09 18:24:59 +08:00
parent d68184fa59
commit f2ac09acdd
3 changed files with 53 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ package middleware
import (
"context"
"net/http"
"strings"
)
const (
@@ -12,7 +13,7 @@ const (
func GlobalSourceInterceptor(next http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// 获取请求头 X-Platform 的值
platform := r.Header.Get(PlatformKey)
platform := strings.TrimSpace(r.Header.Get(PlatformKey))
// 将值放入新的 context 中
ctx := r.Context()