MCPcopy
hub / github.com/seaweedfs/seaweedfs / corsMiddleware

Function corsMiddleware

telemetry/server/main.go:84–99  ·  view source on GitHub ↗
(next http.HandlerFunc)

Source from the content-addressed store, hash-verified

82}
83
84func corsMiddleware(next http.HandlerFunc) http.HandlerFunc {
85 return func(w http.ResponseWriter, r *http.Request) {
86 if *enableCORS {
87 w.Header().Set("Access-Control-Allow-Origin", "*")
88 w.Header().Set("Access-Control-Allow-Methods", "GET, POST, OPTIONS")
89 w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization")
90 }
91
92 if r.Method == "OPTIONS" {
93 w.WriteHeader(http.StatusOK)
94 return
95 }
96
97 next(w, r)
98 }
99}
100
101func logMiddleware(next http.HandlerFunc) http.HandlerFunc {
102 return func(w http.ResponseWriter, r *http.Request) {

Callers 1

mainFunction · 0.85

Calls 4

nextFunction · 0.85
SetMethod · 0.65
HeaderMethod · 0.45
WriteHeaderMethod · 0.45

Tested by

no test coverage detected