mirror of
https://github.com/minio/minio.git
synced 2025-01-29 07:26:00 -05:00
Merge pull request #176 from harshavardhana/pr_out_some_more_cleanup
This commit is contained in:
commit
2bc7ded828
@ -29,6 +29,10 @@ type vHandler struct {
|
|||||||
handler http.Handler
|
handler http.Handler
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type rHandler struct {
|
||||||
|
handler http.Handler
|
||||||
|
}
|
||||||
|
|
||||||
// grab AccessKey from authorization header
|
// grab AccessKey from authorization header
|
||||||
func stripAccessKey(r *http.Request) string {
|
func stripAccessKey(r *http.Request) string {
|
||||||
fields := strings.Fields(r.Header.Get("Authorization"))
|
fields := strings.Fields(r.Header.Get("Authorization"))
|
||||||
@ -78,8 +82,11 @@ func (h vHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ignoreUnimplementedResources(h http.Handler) http.Handler {
|
func ignoreResourcesHandler(h http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return rHandler{h}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h rHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
acceptsContentType := getContentType(r)
|
acceptsContentType := getContentType(r)
|
||||||
if ignoreUnImplementedObjectResources(r) || ignoreUnImplementedBucketResources(r) {
|
if ignoreUnImplementedObjectResources(r) || ignoreUnImplementedBucketResources(r) {
|
||||||
error := errorCodeError(NotImplemented)
|
error := errorCodeError(NotImplemented)
|
||||||
@ -87,9 +94,8 @@ func ignoreUnimplementedResources(h http.Handler) http.Handler {
|
|||||||
w.WriteHeader(error.HttpStatusCode)
|
w.WriteHeader(error.HttpStatusCode)
|
||||||
w.Write(writeErrorResponse(w, errorResponse, acceptsContentType))
|
w.Write(writeErrorResponse(w, errorResponse, acceptsContentType))
|
||||||
} else {
|
} else {
|
||||||
h.ServeHTTP(w, r)
|
h.handler.ServeHTTP(w, r)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//// helpers
|
//// helpers
|
@ -55,5 +55,5 @@ func HttpHandler(storage mstorage.Storage) http.Handler {
|
|||||||
mux.HandleFunc("/{bucket}/{object:.*}", api.headObjectHandler).Methods("HEAD")
|
mux.HandleFunc("/{bucket}/{object:.*}", api.headObjectHandler).Methods("HEAD")
|
||||||
mux.HandleFunc("/{bucket}/{object:.*}", api.putObjectHandler).Methods("PUT")
|
mux.HandleFunc("/{bucket}/{object:.*}", api.putObjectHandler).Methods("PUT")
|
||||||
|
|
||||||
return validateHandler(conf, ignoreUnimplementedResources(mux))
|
return validateHandler(conf, ignoreResourcesHandler(mux))
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user