Avoid trailing '/' for buckets and also re-directs - in accordance with aws clients

This commit is contained in:
Harshavardhana 2015-02-06 20:42:09 -08:00
parent a5bf6b7f14
commit ecb70a4c19
2 changed files with 6 additions and 4 deletions

View file

@ -67,11 +67,9 @@ func HttpHandler(storage mstorage.Storage) http.Handler {
log.Fatal(err)
}
// Re-direct /path to /path/
mux.StrictSlash(true)
mux.HandleFunc("/", api.listBucketsHandler).Methods("GET")
mux.HandleFunc("/{bucket}/", api.listObjectsHandler).Methods("GET")
mux.HandleFunc("/{bucket}/", api.putBucketHandler).Methods("PUT")
mux.HandleFunc("/{bucket}", api.listObjectsHandler).Methods("GET")
mux.HandleFunc("/{bucket}", api.putBucketHandler).Methods("PUT")
mux.HandleFunc("/{bucket}/{object:.*}", api.getObjectHandler).Methods("GET")
mux.HandleFunc("/{bucket}/{object:.*}", api.headObjectHandler).Methods("HEAD")
mux.HandleFunc("/{bucket}/{object:.*}", api.putObjectHandler).Methods("PUT")

View file

@ -47,6 +47,10 @@ func ValidateRequest(user config.User, req *http.Request) (bool, error) {
encoder.Write(hm.Sum(nil))
encoder.Close()
// DEBUG
// fmt.Println("Request header sent: ", req.Header.Get("Authorization"))
// fmt.Println("Header calculated: ", authHeader.String())
// fmt.Printf("%q : %x", ss, ss)
if req.Header.Get("Authorization") != authHeader.String() {
return false, fmt.Errorf("Authorization header mismatch")
}