1 Star 1 Fork 0

Allen / go-scaffold

Create your Gitee Account
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
Clone or download
options.go 1021 Bytes
Copy Edit Raw Blame History
Allen authored 2020-08-18 20:54 . add tls config
// Copyright 2017 David Ackroyd. All Rights Reserved.
// See LICENSE for licensing terms.
package server
import "golang.org/x/net/context"
var (
defaultOptions = &options{
recoveryHandlerFunc: nil,
}
)
type options struct {
recoveryHandlerFunc RecoveryHandlerFuncContext
}
func evaluateOptions(opts []RecoveryOption) *options {
optCopy := &options{}
*optCopy = *defaultOptions
for _, o := range opts {
o(optCopy)
}
return optCopy
}
// Option export
type RecoveryOption func(*options)
// WithRecoveryHandler customizes the function for recovering from a panic.
func WithRecoveryHandler(f RecoveryHandlerFunc) RecoveryOption {
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) RecoveryOption {
return func(o *options) {
o.recoveryHandlerFunc = f
}
}

Comment ( 0 )

Sign in for post a comment

Go
1
https://gitee.com/zakums06/go-scaffold.git
git@gitee.com:zakums06/go-scaffold.git
zakums06
go-scaffold
go-scaffold
v0.1.11

Search