func CorsMW(c *cors.Cors) *CorsMiddleware {
	var mw CorsMiddleware = func(next http.Handler) http.Handler {
		return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			// Wrap the response writer with another that captures the status code.
			scrw := &statusCodeResponseWriter{w, http.StatusOK}

			defer func() {
				// Set status code value on request details so other middlewares can access it.
				if d := getDetails(r); d != nil {
					d.StatusCode = scrw.statusCode
				}
			}()

			// Create the CORS handler.
			h := c.Handler(next)

			// Call the CORS handler with the wrapped response writer.
			h.ServeHTTP(scrw, r)
		})
	}
	return &mw
}
// CorsMW returns a cors middleware that adds cors support to wrapped handlers,
// as defined by the given cors options.
CorsMW returns a cors middleware that adds cors support to wrapped handlers,
as defined by the given cors options.
// CorsMW returns a cors middleware that adds cors support to wrapped handlers // as defined by the given cors options .
func CorsMW(c *cors.Cors) *CorsMiddleware {
	var mw CorsMiddleware = func(next http.Handler) http.Handler {
		return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			scrw := &statusCodeResponseWriter{w, http.StatusOK}
			defer func() {
				if d := getDetails(r); d != nil {
					d.StatusCode = scrw.statusCode
				}
			}()
			h := c.Handler(next)
			h.ServeHTTP(scrw, r)
		})
	}
	return &mw
}
func CorsMW ( c * cors . Cors ) * CorsMiddleware { var mw CorsMiddleware = func ( next http . Handler ) http . Handler { return http . HandlerFunc ( func ( w http . ResponseWriter , r * http . Request ) { scrw := & statusCodeResponseWriter { w , http . StatusOK } defer func ( ) { if d := getDetails ( r ) ; d != nil { d . StatusCode = scrw . statusCode } } ( ) h := c . Handler ( next ) h . ServeHTTP ( scrw , r ) } ) } return & mw }
CorsMW returns a cors middleware that adds cors support to wrapped handlers,
as defined by the given cors options.
CorsMW returns a cors middleware that adds cors support to wrapped handlers as defined by the given cors options .
// Wrap the response writer with another that captures the status code. // Set status code value on request details so other middlewares can access it. // Create the CORS handler. // Call the CORS handler with the wrapped response writer.