Documentation ¶
Index ¶
- Constants
- Variables
- func ClientGrpcStatusAndError(err error) error
- func ClientHTTPStatusAndError(err error) (int, error)
- func NewPrepopulateMiddleware() middleware.Interface
- func ResponseJSONMiddleware() middleware.Interface
- func StreamClientHTTPHeadersInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, ...) (grpc.ClientStream, error)
- func StreamClientQueryTagsInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, ...) (grpc.ClientStream, error)
- func StreamServerHTTPHeadersInterceptor(srv interface{}, ss grpc.ServerStream, _ *grpc.StreamServerInfo, ...) error
- func StreamServerQueryTagsInterceptor(srv interface{}, ss grpc.ServerStream, _ *grpc.StreamServerInfo, ...) error
- func UnaryClientHTTPHeadersInterceptor(ctx context.Context, method string, req, reply interface{}, ...) error
- func UnaryClientQueryTagsInterceptor(ctx context.Context, method string, req, reply interface{}, ...) error
- func UnaryServerHTTPHeadersnIterceptor(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, ...) (interface{}, error)
- func UnaryServerQueryTagsInterceptor(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, ...) (interface{}, error)
- func UnwrapError(s *rpc.Status) error
- func WrapError(err error) *rpc.Status
- func WriteError(err error, w http.ResponseWriter)
Constants ¶
const ( ErrClientCanceled = "The request was cancelled by the client." ErrDeadlineExceeded = "" /* 160-byte string literal not displayed */ )
const StatusClientClosedRequest = 499
StatusClientClosedRequest is the status code for when a client request cancellation of an http request
Variables ¶
var ( RecoveryHTTPMiddleware = middleware.Func(func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { defer func() { if p := recover(); p != nil { WriteError(onPanic(p), w) } }() next.ServeHTTP(w, req) }) }) RecoveryGRPCStreamInterceptor = grpc_recovery.StreamServerInterceptor(grpc_recovery.WithRecoveryHandler(onPanic)) RecoveryGRPCUnaryInterceptor = grpc_recovery.UnaryServerInterceptor(grpc_recovery.WithRecoveryHandler(onPanic)) RecoveryMiddleware queryrangebase.Middleware = queryrangebase.MiddlewareFunc(func(next queryrangebase.Handler) queryrangebase.Handler { return queryrangebase.HandlerFunc(func(ctx context.Context, req queryrangebase.Request) (res queryrangebase.Response, err error) { defer func() { if p := recover(); p != nil { err = onPanic(p) } }() res, err = next.Do(ctx, req) return }) }) )
Functions ¶
func ClientGrpcStatusAndError ¶ added in v3.1.0
func ClientHTTPStatusAndError ¶
ClientHTTPStatusAndError returns error and http status that is "safe" to return to client without exposing any implementation details.
func NewPrepopulateMiddleware ¶
func NewPrepopulateMiddleware() middleware.Interface
NewPrepopulateMiddleware creates a middleware which will parse incoming http forms. This is important because some endpoints can POST x-www-form-urlencoded bodies instead of GET w/ query strings.
func ResponseJSONMiddleware ¶
func ResponseJSONMiddleware() middleware.Interface
ResponseJSONMiddleware sets the Content-Type header to JSON if it's not set.
func StreamClientHTTPHeadersInterceptor ¶
func StreamClientHTTPHeadersInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error)
func StreamClientQueryTagsInterceptor ¶
func StreamClientQueryTagsInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error)
StreamClientQueryTagsInterceptor propagates the query tags from the context to gRPC metadata, which eventually ends up as a HTTP2 header. For streaming gRPC requests.
func StreamServerHTTPHeadersInterceptor ¶
func StreamServerHTTPHeadersInterceptor(srv interface{}, ss grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error
func StreamServerQueryTagsInterceptor ¶
func StreamServerQueryTagsInterceptor(srv interface{}, ss grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error
StreamServerQueryTagsInterceptor propagates the query tags from the gRPC metadata back to our context for streaming gRPC requests.
func UnaryClientHTTPHeadersInterceptor ¶
func UnaryClientHTTPHeadersInterceptor(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error
func UnaryClientQueryTagsInterceptor ¶
func UnaryClientQueryTagsInterceptor(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error
UnaryClientQueryTagsInterceptor propagates the query tags from the context to gRPC metadata, which eventually ends up as a HTTP2 header. For unary gRPC requests.
func UnaryServerHTTPHeadersnIterceptor ¶
func UnaryServerHTTPHeadersnIterceptor(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
func UnaryServerQueryTagsInterceptor ¶
func UnaryServerQueryTagsInterceptor(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
UnaryServerQueryTagsInterceptor propagates the query tags from the gRPC metadata back to our context for unary gRPC requests.
func UnwrapError ¶
func WriteError ¶
func WriteError(err error, w http.ResponseWriter)
WriteError write a go error with the correct status code.
Types ¶
This section is empty.