-
Notifications
You must be signed in to change notification settings - Fork 7
/
options.go
43 lines (36 loc) · 1.05 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package jwt
import (
"time"
)
// Option is the interface that allows to set the options.
type Option func(c *JWT)
// WithExpirationTime set the JWT expiration time.
func WithExpirationTime(expirationTime time.Duration) Option {
return func(c *JWT) {
c.expirationTime = expirationTime
}
}
// WithRenewTime set the time before the JWT expiration when the renewal is allowed.
func WithRenewTime(renewTime time.Duration) Option {
return func(c *JWT) {
c.renewTime = renewTime
}
}
// WithSendResponseFn set the function used to send back the HTTP responses.
func WithSendResponseFn(sendResponseFn SendResponseFn) Option {
return func(c *JWT) {
c.sendResponseFn = sendResponseFn
}
}
// WithAuthorizationHeader sets the authorization header name.
func WithAuthorizationHeader(authorizationHeader string) Option {
return func(c *JWT) {
c.authorizationHeader = authorizationHeader
}
}
// WithSigningMethod sets the signing method function.
func WithSigningMethod(signingMethod SigningMethod) Option {
return func(c *JWT) {
c.signingMethod = signingMethod
}
}