func (sc *SqlCollector) SetConfig(cfg *config.Config) (err error) { if sc.driver, err = cfg.String("driver"); err != nil { return err } if sc.datasource, err = cfg.String("datasource"); err != nil { return err } if sc.query, err = cfg.String("query"); err != nil { return err } sc.interval = cfg.UInt("interval", 3600) return nil }
func session(config *config.Config) (s sessions.Store, err error) { secret := []byte(config.UString("secret", "go-default-secret")) t := config.UString("type", "cookie") switch t { case "cookie": s = sessions.NewCookieStore(secret) case "redis": s, err = sessions.NewRedisStore( config.UInt("size"), config.UString("network"), config.UString("address"), config.UString("password"), secret, ) default: err = errors.New("No session type allowed.") } if err != nil { return nil, err } o, _ := config.Get("options") if o != nil { s.Options(sessions.Options{ Path: o.UString("path"), Domain: o.UString("domain"), MaxAge: o.UInt("max_age", int(30*time.Minute)), Secure: o.UBool("secure"), HttpOnly: o.UBool("http_only"), }) } return s, nil }