Add CORS support to minio s3 server

master
Krishna Srinivas 9 years ago
parent d5d4c7046f
commit 1e82ee1192
  1. 5
      pkg/server/api/generic-handlers.go
  2. 1
      pkg/server/router.go

@ -22,6 +22,7 @@ import (
"time" "time"
"github.com/minio/minio/pkg/auth" "github.com/minio/minio/pkg/auth"
"github.com/rs/cors"
) )
type contentTypeHandler struct { type contentTypeHandler struct {
@ -150,6 +151,10 @@ func (h validateAuthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
} }
} }
func CorsHandler(h http.Handler) http.Handler {
return cors.Default().Handler(h)
}
// IgnoreResourcesHandler - // IgnoreResourcesHandler -
// Ignore resources handler is wrapper handler used for API request resource validation // Ignore resources handler is wrapper handler used for API request resource validation
// Since we do not support all the S3 queries, it is necessary for us to throw back a // Since we do not support all the S3 queries, it is necessary for us to throw back a

@ -85,6 +85,7 @@ func registerCustomMiddleware(mux http.Handler, conf api.Config) http.Handler {
api.IgnoreResourcesHandler, api.IgnoreResourcesHandler,
api.ValidateAuthHeaderHandler, api.ValidateAuthHeaderHandler,
api.LoggingHandler, api.LoggingHandler,
api.CorsHandler,
// Add new your new middleware here // Add new your new middleware here
) )

Loading…
Cancel
Save