API can respond directly []byte (like files)
This commit is contained in:
parent
a1d60ee78f
commit
9324f6f5fa
|
@ -87,6 +87,9 @@ func (a apiRouting) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
if str, found := ret.(string); found {
|
||||
w.WriteHeader(resStatus)
|
||||
io.WriteString(w, str)
|
||||
} else if bts, found := ret.([]byte); found {
|
||||
w.WriteHeader(resStatus)
|
||||
w.Write(bts)
|
||||
} else if j, err := json.Marshal(ret); err != nil {
|
||||
http.Error(w, fmt.Sprintf("{\"errmsg\":\"%q\"}", err), http.StatusInternalServerError)
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue