mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-05 08:55:28 +08:00
22 lines
400 B
Go
22 lines
400 B
Go
package openai
|
|
|
|
import (
|
|
"net/http"
|
|
"strings"
|
|
|
|
"github.com/go-chi/chi/v5/middleware"
|
|
)
|
|
|
|
func requestTraceID(r *http.Request) string {
|
|
if r == nil {
|
|
return ""
|
|
}
|
|
if q := strings.TrimSpace(r.URL.Query().Get("__trace_id")); q != "" {
|
|
return q
|
|
}
|
|
if h := strings.TrimSpace(r.Header.Get("X-Ds2-Test-Trace")); h != "" {
|
|
return h
|
|
}
|
|
return strings.TrimSpace(middleware.GetReqID(r.Context()))
|
|
}
|