aboutsummaryrefslogtreecommitdiff
path: root/weed/s3api/s3err/error_handler.go
diff options
context:
space:
mode:
authorLHHDZ <changlin.shi@ly.com>2022-10-02 10:18:00 +0800
committerGitHub <noreply@github.com>2022-10-01 19:18:00 -0700
commite9584d96615870176d9fd5317b31695e87ff7b7e (patch)
tree279e2eaca22ac6847c9cfcc946ccd6d9f1eb5329 /weed/s3api/s3err/error_handler.go
parent6fa3d0cc463fd866828ee071d295eab4eb725f4b (diff)
downloadseaweedfs-e9584d96615870176d9fd5317b31695e87ff7b7e.tar.xz
seaweedfs-e9584d96615870176d9fd5317b31695e87ff7b7e.zip
add ownership rest apis (#3765)
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)
}