This repository has been archived on 2022-12-28. You can view files and clone it, but cannot push or open issues or pull requests.
2021-06-20 15:22:39 +08:00

19 lines
458 B
Go

package errors
import (
"net/http"
"encoding/json"
)
func ResponseError(w http.ResponseWriter,r *http.Request,httpCode int,info string,errorCode int) {
w.Header().Set("Content-Type","application/json")
w.WriteHeader(httpCode)
type returnError struct{
HttpCode int `json:"httpCode"`
Info string `json:"info"`
ErrorCode int `json:"errorCode"`
}
returnInfo:=returnError{httpCode,info,errorCode}
b,_:=json.Marshal(returnInfo)
w.Write(b)
}