MCPcopy Index your code
hub / github.com/PatchMon/PatchMon / EffectiveOrigin

Function EffectiveOrigin

server-source-code/internal/middleware/cors.go:153–164  ·  view source on GitHub ↗

EffectiveOrigin derives an origin URL from the request and host. Used for CORS headers and for dynamic per-host origin resolution.

(r *http.Request, host string)

Source from the content-addressed store, hash-verified

151// EffectiveOrigin derives an origin URL from the request and host.
152// Used for CORS headers and for dynamic per-host origin resolution.
153func EffectiveOrigin(r *http.Request, host string) string {
154 if host == "" {
155 return ""
156 }
157 scheme := "https"
158 if proto := r.Header.Get("X-Forwarded-Proto"); proto != "" {
159 scheme = strings.ToLower(proto)
160 } else if r.TLS == nil {
161 scheme = "http"
162 }
163 return scheme + "://" + host
164}
165
166// buildAllowedHosts extracts host[:port] from each origin URL.
167// E.g. "http://patchmon-local:3000" -> "patchmon-local:3000".

Callers 1

CORSFunction · 0.85

Calls 1

GetMethod · 0.45

Tested by

no test coverage detected