fix golint issues in rest (#529)
This commit is contained in:
@@ -28,15 +28,19 @@ var (
|
||||
)
|
||||
|
||||
type (
|
||||
// A AuthorizeOptions is authorize options.
|
||||
AuthorizeOptions struct {
|
||||
PrevSecret string
|
||||
Callback UnauthorizedCallback
|
||||
}
|
||||
|
||||
// UnauthorizedCallback defines the method of unauthorized callback.
|
||||
UnauthorizedCallback func(w http.ResponseWriter, r *http.Request, err error)
|
||||
AuthorizeOption func(opts *AuthorizeOptions)
|
||||
// AuthorizeOption defines the method to customize an AuthorizeOptions.
|
||||
AuthorizeOption func(opts *AuthorizeOptions)
|
||||
)
|
||||
|
||||
// Authorize returns an authorize middleware.
|
||||
func Authorize(secret string, opts ...AuthorizeOption) func(http.Handler) http.Handler {
|
||||
var authOpts AuthorizeOptions
|
||||
for _, opt := range opts {
|
||||
@@ -78,12 +82,14 @@ func Authorize(secret string, opts ...AuthorizeOption) func(http.Handler) http.H
|
||||
}
|
||||
}
|
||||
|
||||
// WithPrevSecret returns an AuthorizeOption with setting previous secret.
|
||||
func WithPrevSecret(secret string) AuthorizeOption {
|
||||
return func(opts *AuthorizeOptions) {
|
||||
opts.PrevSecret = secret
|
||||
}
|
||||
}
|
||||
|
||||
// WithUnauthorizedCallback returns an AuthorizeOption with setting unauthorized callback.
|
||||
func WithUnauthorizedCallback(callback UnauthorizedCallback) AuthorizeOption {
|
||||
return func(opts *AuthorizeOptions) {
|
||||
opts.Callback = callback
|
||||
|
||||
Reference in New Issue
Block a user