ints
This commit is contained in:
parent
b41b96fb69
commit
c3e5e5d8da
1 changed files with 10 additions and 3 deletions
|
@ -20,7 +20,7 @@ func init() {
|
|||
type KeyDBHandler struct {
|
||||
Address string `json:"address"`
|
||||
Password string `json:"password"`
|
||||
DB int `json:"db"`
|
||||
DB string `json:"db"`
|
||||
client *redis.Client
|
||||
}
|
||||
|
||||
|
@ -32,10 +32,17 @@ func (KeyDBHandler) CaddyModule() caddy.ModuleInfo {
|
|||
}
|
||||
|
||||
func (h *KeyDBHandler) Provision(ctx caddy.Context) error {
|
||||
db, err := strconv.Atoi(h.DB)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if db < 0 || db > 15 {
|
||||
return fmt.Errorf("invalid db value: %d", db)
|
||||
}
|
||||
h.client = redis.NewClient(&redis.Options{
|
||||
Addr: h.Address,
|
||||
Password: h.Password,
|
||||
DB: h.DB,
|
||||
DB: db,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
@ -76,7 +83,7 @@ func (h *KeyDBHandler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
|
|||
return d.ArgErr()
|
||||
}
|
||||
case "db":
|
||||
if !d.Args(strconv.Itoa(h.DB)) {
|
||||
if !d.Args(&h.DB) {
|
||||
return d.ArgErr()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue