Avoid checking date header of web requests by properly applying generic handlers (#2914)

This commit is contained in:
Anis Elleuch
2016-10-12 20:58:36 +01:00
committed by Harshavardhana
parent 73982c8cb6
commit df59967f59
13 changed files with 965 additions and 13 deletions

View File

@@ -16,7 +16,10 @@
package cmd
import router "github.com/gorilla/mux"
import (
router "github.com/gorilla/mux"
"github.com/urfave/negroni"
)
// objectAPIHandler implements and provides http handlers for S3 API.
type objectAPIHandlers struct {
@@ -31,7 +34,7 @@ func registerAPIRouter(mux *router.Router) {
}
// API Router
apiRouter := mux.NewRoute().PathPrefix("/").Subrouter()
apiRouter := router.NewRouter().PathPrefix("/").Subrouter()
// Bucket router
bucket := apiRouter.PathPrefix("/{bucket}").Subrouter()
@@ -96,4 +99,12 @@ func registerAPIRouter(mux *router.Router) {
// ListBuckets
apiRouter.Methods("GET").HandlerFunc(api.ListBucketsHandler)
mux.PathPrefix("/").Handler(negroni.New(
// Validates all incoming requests to have a valid date header.
negroni.Wrap(timeValidityHandler{}),
// Route requests
negroni.Wrap(apiRouter),
))
}