Browse Source

Updated sleepy to 05901e834c

pull/28/head
Simon Eisenmann 11 years ago
parent
commit
62e160d7b7
  1. 21
      src/app/spreed-speakfreely-server/sleepy/core.go

21
src/app/spreed-speakfreely-server/sleepy/core.go

@ -148,7 +148,26 @@ func (api *API) requestHandler(resource interface{}) http.HandlerFunc { @@ -148,7 +148,26 @@ func (api *API) requestHandler(resource interface{}) http.HandlerFunc {
code, data, header := handler(request)
content, err := json.MarshalIndent(data, "", " ")
var content []byte
var err error
switch data.(type) {
case string:
content = []byte(data.(string))
case []byte:
content = data.([]byte)
default:
// Encode JSON.
content, err = json.MarshalIndent(data, "", " ")
if err != nil {
if header == nil {
header = http.Header{"Content-Type": {"application/json"}}
} else if header.Get("Content-Type") == "" {
header.Set("Content-Type", "application/json")
}
}
}
if err != nil {
rw.WriteHeader(http.StatusInternalServerError)
return

Loading…
Cancel
Save