-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.go
45 lines (38 loc) · 988 Bytes
/
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
44
45
package httpcache
import (
"time"
)
func WithDeniedStatusCodes(deniedStatusCodes []int) func(*CachedRoundTripper) error {
return func(c *CachedRoundTripper) error {
c.deniedStatusCodes = deniedStatusCodes
return nil
}
}
func WithAllowedStatusCodes(allowedStatusCodes []int) func(*CachedRoundTripper) error {
return func(c *CachedRoundTripper) error {
c.allowedStatusCodes = allowedStatusCodes
return nil
}
}
func WithExpiryTime(expiryTime time.Duration) func(*CachedRoundTripper) error {
return func(c *CachedRoundTripper) error {
c.expiryTime = expiryTime
return nil
}
}
func WithName(name string) func(*CachedRoundTripper) error {
return func(c *CachedRoundTripper) error {
sqliteStore, err := newSqliteResponseStore(name)
if err != nil {
return err
}
c.store = sqliteStore
return nil
}
}
func WithCacheStore(store ResponseStorer) func(*CachedRoundTripper) error {
return func(c *CachedRoundTripper) error {
c.store = store
return nil
}
}