13
vendor/github.com/grpc-ecosystem/go-grpc-middleware/recovery/options.go
generated
vendored
13
vendor/github.com/grpc-ecosystem/go-grpc-middleware/recovery/options.go
generated
vendored
@@ -3,6 +3,8 @@
|
||||
|
||||
package grpc_recovery
|
||||
|
||||
import "context"
|
||||
|
||||
var (
|
||||
defaultOptions = &options{
|
||||
recoveryHandlerFunc: nil,
|
||||
@@ -10,7 +12,7 @@ var (
|
||||
)
|
||||
|
||||
type options struct {
|
||||
recoveryHandlerFunc RecoveryHandlerFunc
|
||||
recoveryHandlerFunc RecoveryHandlerFuncContext
|
||||
}
|
||||
|
||||
func evaluateOptions(opts []Option) *options {
|
||||
@@ -26,6 +28,15 @@ type Option func(*options)
|
||||
|
||||
// WithRecoveryHandler customizes the function for recovering from a panic.
|
||||
func WithRecoveryHandler(f RecoveryHandlerFunc) Option {
|
||||
return func(o *options) {
|
||||
o.recoveryHandlerFunc = RecoveryHandlerFuncContext(func(ctx context.Context, p interface{}) error {
|
||||
return f(p)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// WithRecoveryHandlerContext customizes the function for recovering from a panic.
|
||||
func WithRecoveryHandlerContext(f RecoveryHandlerFuncContext) Option {
|
||||
return func(o *options) {
|
||||
o.recoveryHandlerFunc = f
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user