MCPcopy Index your code
hub / github.com/PasarGuard/node / GrpcCodeToHTTP

Function GrpcCodeToHTTP

common/helper.go:68–103  ·  view source on GitHub ↗

GrpcCodeToHTTP maps gRPC codes to HTTP status codes.

(code codes.Code)

Source from the content-addressed store, hash-verified

66
67// GrpcCodeToHTTP maps gRPC codes to HTTP status codes.
68func GrpcCodeToHTTP(code codes.Code) int {
69 switch code {
70 case codes.OK:
71 return http.StatusOK
72 case codes.Canceled:
73 return 499 // client closed request
74 case codes.InvalidArgument:
75 return http.StatusBadRequest
76 case codes.Unauthenticated:
77 return http.StatusUnauthorized
78 case codes.PermissionDenied:
79 return http.StatusForbidden
80 case codes.NotFound:
81 return http.StatusNotFound
82 case codes.AlreadyExists:
83 return http.StatusConflict
84 case codes.ResourceExhausted:
85 return http.StatusTooManyRequests
86 case codes.FailedPrecondition:
87 return http.StatusPreconditionFailed
88 case codes.Aborted:
89 return http.StatusConflict
90 case codes.OutOfRange:
91 return http.StatusBadRequest
92 case codes.Unimplemented:
93 return http.StatusNotImplemented
94 case codes.Internal:
95 return http.StatusInternalServerError
96 case codes.Unavailable:
97 return http.StatusServiceUnavailable
98 case codes.DeadlineExceeded:
99 return http.StatusGatewayTimeout
100 default:
101 return http.StatusInternalServerError
102 }
103}
104
105// InterceptNotFound checks for errors ending with "not found."
106// and wraps them as gRPC NotFound.

Callers 4

GetStatsMethod · 0.92
GetUserOnlineStatMethod · 0.92
GetBackendStatsMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected