mirror of
https://github.com/go-kratos/kratos.git
synced 2025-02-01 13:07:48 +02:00
parent
5051609aef
commit
af14c07762
@ -9,6 +9,11 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
baseContentType = "application"
|
baseContentType = "application"
|
||||||
|
|
||||||
|
// StatusClientClosed is non-standard http status code,
|
||||||
|
// which defined by nginx.
|
||||||
|
// https://httpstatus.in/499/
|
||||||
|
StatusClientClosed = 499
|
||||||
)
|
)
|
||||||
|
|
||||||
// ContentType returns the content-type with base prefix.
|
// ContentType returns the content-type with base prefix.
|
||||||
@ -62,6 +67,8 @@ func GRPCCodeFromStatus(code int) codes.Code {
|
|||||||
return codes.Unavailable
|
return codes.Unavailable
|
||||||
case http.StatusGatewayTimeout:
|
case http.StatusGatewayTimeout:
|
||||||
return codes.DeadlineExceeded
|
return codes.DeadlineExceeded
|
||||||
|
case StatusClientClosed:
|
||||||
|
return codes.Canceled
|
||||||
}
|
}
|
||||||
return codes.Unknown
|
return codes.Unknown
|
||||||
}
|
}
|
||||||
@ -73,7 +80,7 @@ func StatusFromGRPCCode(code codes.Code) int {
|
|||||||
case codes.OK:
|
case codes.OK:
|
||||||
return http.StatusOK
|
return http.StatusOK
|
||||||
case codes.Canceled:
|
case codes.Canceled:
|
||||||
return http.StatusRequestTimeout
|
return StatusClientClosed
|
||||||
case codes.Unknown:
|
case codes.Unknown:
|
||||||
return http.StatusInternalServerError
|
return http.StatusInternalServerError
|
||||||
case codes.InvalidArgument:
|
case codes.InvalidArgument:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user