simplify probe APIs

This commit is contained in:
Anand Babu (AB) Periasamy
2015-08-18 19:30:17 -07:00
parent 76d11ed1e4
commit cdf93e534c
11 changed files with 104 additions and 119 deletions

View File

@@ -47,7 +47,7 @@ func (api Minio) isValidOp(w http.ResponseWriter, req *http.Request, acceptsCont
}
return true
}
switch err.ToError().(type) {
switch err.ToGoError().(type) {
case donut.BucketNotFound:
writeErrorResponse(w, req, NoSuchBucket, acceptsContentType, req.URL.Path)
return false
@@ -117,7 +117,7 @@ func (api Minio) ListMultipartUploadsHandler(w http.ResponseWriter, req *http.Re
w.Write(encodedSuccessResponse)
return
}
switch err.ToError().(type) {
switch err.ToGoError().(type) {
case donut.SignatureDoesNotMatch:
writeErrorResponse(w, req, SignatureDoesNotMatch, acceptsContentType, req.URL.Path)
case donut.BucketNotFound:
@@ -188,7 +188,7 @@ func (api Minio) ListObjectsHandler(w http.ResponseWriter, req *http.Request) {
w.Write(encodedSuccessResponse)
return
}
switch err.ToError().(type) {
switch err.ToGoError().(type) {
case donut.SignatureDoesNotMatch:
writeErrorResponse(w, req, SignatureDoesNotMatch, acceptsContentType, req.URL.Path)
case donut.BucketNameInvalid:
@@ -249,7 +249,7 @@ func (api Minio) ListBucketsHandler(w http.ResponseWriter, req *http.Request) {
w.Write(encodedSuccessResponse)
return
}
switch err.ToError().(type) {
switch err.ToGoError().(type) {
case donut.SignatureDoesNotMatch:
writeErrorResponse(w, req, SignatureDoesNotMatch, acceptsContentType, req.URL.Path)
default:
@@ -321,7 +321,7 @@ func (api Minio) PutBucketHandler(w http.ResponseWriter, req *http.Request) {
writeSuccessResponse(w, acceptsContentType)
return
}
switch err.ToError().(type) {
switch err.ToGoError().(type) {
case donut.SignatureDoesNotMatch:
writeErrorResponse(w, req, SignatureDoesNotMatch, acceptsContentType, req.URL.Path)
case donut.TooManyBuckets:
@@ -377,7 +377,7 @@ func (api Minio) PutBucketACLHandler(w http.ResponseWriter, req *http.Request) {
writeSuccessResponse(w, acceptsContentType)
return
}
switch err.ToError().(type) {
switch err.ToGoError().(type) {
case donut.SignatureDoesNotMatch:
writeErrorResponse(w, req, SignatureDoesNotMatch, acceptsContentType, req.URL.Path)
case donut.BucketNameInvalid:
@@ -427,7 +427,7 @@ func (api Minio) HeadBucketHandler(w http.ResponseWriter, req *http.Request) {
writeSuccessResponse(w, acceptsContentType)
return
}
switch err.ToError().(type) {
switch err.ToGoError().(type) {
case donut.SignatureDoesNotMatch:
writeErrorResponse(w, req, SignatureDoesNotMatch, acceptsContentType, req.URL.Path)
case donut.BucketNotFound:

View File

@@ -80,7 +80,7 @@ func (api Minio) GetObjectHandler(w http.ResponseWriter, req *http.Request) {
}
return
}
switch err.ToError().(type) {
switch err.ToGoError().(type) {
case donut.SignatureDoesNotMatch:
writeErrorResponse(w, req, SignatureDoesNotMatch, acceptsContentType, req.URL.Path)
case donut.BucketNameInvalid:
@@ -137,7 +137,7 @@ func (api Minio) HeadObjectHandler(w http.ResponseWriter, req *http.Request) {
w.WriteHeader(http.StatusOK)
return
}
switch err.ToError().(type) {
switch err.ToGoError().(type) {
case donut.SignatureDoesNotMatch:
writeErrorResponse(w, req, SignatureDoesNotMatch, acceptsContentType, req.URL.Path)
case donut.BucketNameInvalid:
@@ -231,7 +231,7 @@ func (api Minio) PutObjectHandler(w http.ResponseWriter, req *http.Request) {
writeSuccessResponse(w, acceptsContentType)
return
}
switch err.ToError().(type) {
switch err.ToGoError().(type) {
case donut.BucketNotFound:
writeErrorResponse(w, req, NoSuchBucket, acceptsContentType, req.URL.Path)
case donut.BucketNameInvalid:
@@ -305,7 +305,7 @@ func (api Minio) NewMultipartUploadHandler(w http.ResponseWriter, req *http.Requ
w.Write(encodedSuccessResponse)
return
}
switch err.ToError().(type) {
switch err.ToGoError().(type) {
case donut.SignatureDoesNotMatch:
writeErrorResponse(w, req, SignatureDoesNotMatch, acceptsContentType, req.URL.Path)
case donut.ObjectExists:
@@ -395,7 +395,7 @@ func (api Minio) PutObjectPartHandler(w http.ResponseWriter, req *http.Request)
writeSuccessResponse(w, acceptsContentType)
return
}
switch err.ToError().(type) {
switch err.ToGoError().(type) {
case donut.InvalidUploadID:
writeErrorResponse(w, req, NoSuchUpload, acceptsContentType, req.URL.Path)
case donut.ObjectExists:
@@ -455,7 +455,7 @@ func (api Minio) AbortMultipartUploadHandler(w http.ResponseWriter, req *http.Re
w.WriteHeader(http.StatusNoContent)
return
}
switch err.ToError().(type) {
switch err.ToGoError().(type) {
case donut.SignatureDoesNotMatch:
writeErrorResponse(w, req, SignatureDoesNotMatch, acceptsContentType, req.URL.Path)
case donut.InvalidUploadID:
@@ -520,7 +520,7 @@ func (api Minio) ListObjectPartsHandler(w http.ResponseWriter, req *http.Request
w.Write(encodedSuccessResponse)
return
}
switch err.ToError().(type) {
switch err.ToGoError().(type) {
case donut.SignatureDoesNotMatch:
writeErrorResponse(w, req, SignatureDoesNotMatch, acceptsContentType, req.URL.Path)
case donut.InvalidUploadID:
@@ -573,7 +573,7 @@ func (api Minio) CompleteMultipartUploadHandler(w http.ResponseWriter, req *http
w.Write(encodedSuccessResponse)
return
}
switch err.ToError().(type) {
switch err.ToGoError().(type) {
case donut.InvalidUploadID:
writeErrorResponse(w, req, NoSuchUpload, acceptsContentType, req.URL.Path)
case donut.InvalidPart:

View File

@@ -49,7 +49,7 @@ func getAuth(reply *AuthReply) *probe.Error {
// Get auth keys
func (s *AuthService) Get(r *http.Request, args *Args, reply *AuthReply) error {
if err := getAuth(reply); err != nil {
return probe.NewWrappedError(err)
return probe.WrapError(err)
}
return nil
}

View File

@@ -57,7 +57,7 @@ func setDonut(args *DonutArgs, reply *Reply) *probe.Error {
// Set method
func (s *DonutService) Set(r *http.Request, args *DonutArgs, reply *Reply) error {
if err := setDonut(args, reply); err != nil {
return probe.NewWrappedError(err)
return probe.WrapError(err)
}
return nil
}

View File

@@ -70,7 +70,7 @@ func setMemStatsReply(sis *MemStatsReply) *probe.Error {
// Get method
func (s *SysInfoService) Get(r *http.Request, args *Args, reply *SysInfoReply) error {
if err := setSysInfoReply(reply); err != nil {
return probe.NewWrappedError(err)
return probe.WrapError(err)
}
return nil
}
@@ -78,7 +78,7 @@ func (s *SysInfoService) Get(r *http.Request, args *Args, reply *SysInfoReply) e
// Get method
func (s *MemStatsService) Get(r *http.Request, args *Args, reply *MemStatsReply) error {
if err := setMemStatsReply(reply); err != nil {
return probe.NewWrappedError(err)
return probe.WrapError(err)
}
return nil
}