add ownership rest apis (#3765)

This commit is contained in:
LHHDZ authored and GitHub committed 2022-10-01 19:18:00 -07:00
1 parent 6fa3d0cc46
commit e9584d9661
9 files changed
+356 -1

No files matched your search

+11
View File
@@ -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)
}