Ejemplo n.º 1
0
// GetString returns a string from the manager. Example usage:
// Default value: GetString(config.Path("general/locale/timezone"))
// Website value: GetString(config.Path("general/locale/timezone"), config.ScopeWebsite(w))
// Store   value: GetString(config.Path("general/locale/timezone"), config.ScopeStore(s))
func (m *Manager) GetString(o ...ArgFunc) (string, error) {
	vs := m.get(o...)
	if vs == nil {
		return "", ErrKeyNotFound
	}
	return cast.ToStringE(vs)
}
Ejemplo n.º 2
0
func appendTokenToForm(r *http.Request, t *jwt.Token, prefix string) error {

	if r.Method == "POST" || r.Method == "PUT" || r.Method == "PATCH" {
		if err := r.ParseForm(); err != nil {
			return err
		}
	}

	if r.Form == nil {
		r.Form = make(url.Values)
	}

	for k, v := range t.Claims {
		vs, err := cast.ToStringE(v)
		if err == nil {
			r.Form.Add(prefix+k, vs)
		} else {
			return errgo.Newf("appendTokenToForm: failed to assert to type string: key %s => value %v : %s", k, v, err.Error())
		}
	}

	return nil
}