up(proxy response)
This commit is contained in:
1 parent
1a46b678ef
commit
f802b2000d
11 files changed
+108
-159
No files matched your search
@@ -0,0 +1,26 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/integration-system/isp-lib/http"
|
||||
"github.com/integration-system/isp-lib/structure"
|
||||
"github.com/valyala/fasthttp"
|
||||
"google.golang.org/grpc/codes"
|
||||
)
|
||||
|
||||
const JsonContentType = "application/json; charset=utf-8"
|
||||
|
||||
func WriteError(ctx *fasthttp.RequestCtx, message string, code codes.Code, details []interface{}) {
|
||||
grpcCode := code.String()
|
||||
|
||||
structureError := structure.GrpcError{
|
||||
ErrorMessage: message,
|
||||
ErrorCode: grpcCode,
|
||||
Details: details,
|
||||
}
|
||||
|
||||
ctx.SetContentType(JsonContentType)
|
||||
ctx.SetStatusCode(http.CodeToHttpStatus(code))
|
||||
msg, _ := json.Marshal(structureError)
|
||||
_, _ = ctx.Write(msg)
|
||||
}
|
||||
Reference in new issue
Block a user