19 lines
458 B
Go
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)
|
|
} |