aboutsummaryrefslogtreecommitdiff
path: root/weed/s3api/s3err/error_handler.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/s3api/s3err/error_handler.go')
-rw-r--r--weed/s3api/s3err/error_handler.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/weed/s3api/s3err/error_handler.go b/weed/s3api/s3err/error_handler.go
index 6c3f13938..3fb04a313 100644
--- a/weed/s3api/s3err/error_handler.go
+++ b/weed/s3api/s3err/error_handler.go
@@ -4,6 +4,7 @@ import (
"bytes"
"encoding/xml"
"fmt"
+ "github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil"
"github.com/gorilla/mux"
"github.com/seaweedfs/seaweedfs/weed/glog"
"net/http"
@@ -19,6 +20,16 @@ const (
MimeXML mimeType = "application/xml"
)
+func WriteAwsXMLResponse(w http.ResponseWriter, r *http.Request, statusCode int, result interface{}) {
+ var bytesBuffer bytes.Buffer
+ err := xmlutil.BuildXML(result, xml.NewEncoder(&bytesBuffer))
+ if err != nil {
+ WriteErrorResponse(w, r, ErrInternalError)
+ return
+ }
+ WriteResponse(w, r, statusCode, bytesBuffer.Bytes(), MimeXML)
+}
+
func WriteXMLResponse(w http.ResponseWriter, r *http.Request, statusCode int, response interface{}) {
WriteResponse(w, r, statusCode, EncodeXMLResponse(response), MimeXML)
}