1
0
Fork 0
mirror of https://github.com/chrislusf/seaweedfs synced 2024-06-15 07:03:16 +02:00
seaweedfs/weed/s3api/s3api_headers.go
2018-07-18 02:37:09 -07:00

32 lines
637 B
Go

package s3api
import (
"bytes"
"encoding/xml"
"fmt"
"net/http"
"time"
)
type mimeType string
const (
mimeNone mimeType = ""
mimeJSON mimeType = "application/json"
mimeXML mimeType = "application/xml"
)
func setCommonHeaders(w http.ResponseWriter) {
w.Header().Set("x-amz-request-id", fmt.Sprintf("%d", time.Now().UnixNano()))
w.Header().Set("Accept-Ranges", "bytes")
}
// Encodes the response headers into XML format.
func encodeResponse(response interface{}) []byte {
var bytesBuffer bytes.Buffer
bytesBuffer.WriteString(xml.Header)
e := xml.NewEncoder(&bytesBuffer)
e.Encode(response)
return bytesBuffer.Bytes()
}