MCPcopy
hub / github.com/OpenNHP/opennhp / corsMiddleware

Function corsMiddleware

examples/server_plugin/basic/main.go:320–329  ·  view source on GitHub ↗
(ctx *gin.Context)

Source from the content-addressed store, hash-verified

318}
319
320func corsMiddleware(ctx *gin.Context) {
321 originResource := ctx.Request.Header.Get("Origin")
322
323 if originResource != "" {
324 // HTTP headers for CORS
325 ctx.Writer.Header().Set("Access-Control-Allow-Origin", originResource) // allow cross-origin resource sharing
326 }
327
328 ctx.Next()
329}
330
331func main() {
332

Callers 1

AuthWithHttpFunction · 0.70

Calls 3

SetMethod · 0.80
HeaderMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected