// Store form parameter value of specified key to *val and return true; if key does not exist, set HTTP status 400 and return false.
356797
func Require(w http.ResponseWriter, r *http.Request, key string, val *string) bool {
	*val = r.FormValue(key)
	if *val == "" {
		http.Error(w, fmt.Sprintf("Please pass POST/PUT/GET parameter value of '%s'.", key), 400)
		return false
	}
	return true
}
841886
func (s *SuperAgent) Param(key string, value string) *SuperAgent {
	s.QueryData.Add(key, value)
	return s
}
72539
func (i *InternalTokenHelper) Store(input string) error {
	i.populateTokenPath()
	f, err := os.OpenFile(i.tokenPath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600)
	if err != nil {
		return err
	}
	defer f.Close()

	buf := bytes.NewBufferString(input)
	if _, err := io.Copy(f, buf); err != nil {
		return err
	}

	return nil
}
1110087
func (p *Loader) storeRequest(id stellar1.KeybaseRequestID, request *stellar1.RequestDetailsLocal) (isUpdate bool) {
	p.Lock()
	x, ok := p.requests[id]
	if !ok || x.Status != request.Status {
		isUpdate = true
	}
	p.requests[id] = request
	p.rlist = append(p.rlist, id)
	p.Unlock()

	return isUpdate
}
290750
func (c *APIContext) Value(key interface{}) interface{} {
	if keyAsString, ok := key.(string); ok {
		val, _ := c.Get(keyAsString)
		return val
	}
	return nil
}
1350947
func (req *Request) PostFormValue(key string) (value string) {
	valueList := req.controller.Params.Form[key]
	if len(valueList) > 0 {
		value = valueList[0]
	}
	return
}
540377
func (m *boxMap) Store(key string, value *Box) {
	m.data.Store(key, value)
}
209492
func (c *Context) Value(key interface{}) interface{} {
	if key == 0 {
		return c.Request
	}
	if keyAsString, ok := key.(string); ok {
		val, _ := c.Get(keyAsString)
		return val
	}
	return nil
}
707611
func Form(r *http.Request, i interface{}) error {
	//convert form and validate
	var err error
	v := reflect.ValueOf(i).Elem()
	//t := reflect.TypeOf(item)
	if strings.Contains(r.Header.Get("content-type"), "/json") {

		decoder := json.NewDecoder(r.Body)
		err := decoder.Decode(i)
		if err != nil {
			return err
		}

		_, err = govalidator.ValidateStruct(i)
		if err != nil {
			return err
		}
	} else {

		bso := bson.M{"__elem": "form"}

		for i := 0; i < v.NumField(); i++ {
			field := v.Type().Field(i)
			fieldtype := strings.ToLower(field.Type.String())
			if strings.Contains(fieldtype, "file") {
				file, handler, _ := r.FormFile(field.Name)

				if handler != nil {
					fid := fmt.Sprintf("%s-%s", core.NewLen(15), handler.Filename)
					f, err := os.OpenFile(fmt.Sprintf("./uploads/%s", fid), os.O_WRONLY|os.O_CREATE, 0700)
					if err != nil {

						return err
					}

					io.Copy(f, file)
					f.Close()
					bso[field.Name] = fid
					file.Close()
				}
			} else if strings.Contains(fieldtype, "bool") {
				bso[field.Name] = strings.Contains(r.FormValue(field.Name), "on")
			} else if strings.Contains(fieldtype, "password") {
				bso[field.Name] = Hash(r.FormValue(field.Name))
			} else if strings.Contains(fieldtype, "int") {
				i, _ := strconv.Atoi(r.FormValue(field.Name))
				bso[field.Name] = i
			} else if strings.Contains(fieldtype, "float") {
				f, _ := strconv.ParseFloat(r.FormValue(field.Name), 64)
				bso[field.Name] = f
			} else {
				bso[field.Name] = r.FormValue(field.Name)

			}

		}

		data, _ := json.Marshal(&bso)
		json.Unmarshal([]byte(data), i)

		_, err = govalidator.ValidateStruct(i)
		if err != nil {
			return err
		}
	}
	return nil
	//ValidateStruct
}
897509
func (s Store) GetValue(key string, v ...string) (string, error) {
	kv, err := s.Get(key)
	if err != nil {
		if len(v) > 0 {
			// Take default
			return v[0], nil
		}
		return "", err
	}
	return kv.Value, nil
}
876342
func (f *Values) Add(key, val string) {
	f.values = append(f.values, formValue{key, val})
}
98004
func (r Request) PostForm(params map[string]string) (Request, error) {
	return reqForm(r, params, "POST")
}
447411
func (store DataStore) Save(key string, item interface{}) error {
	encodedItem, err := store.Encoding.Encode(item)
	if err != nil {
		return err
	}
	return SetItem(key, string(encodedItem))
}
174927
func (r *Request) GetValue(key int) (value interface{}) {
	value, _ = r.In.Get(key)
	return
}
1134316
func (k *Client) Param(key string, value string) {
	k.QueryData.Add(key, value)

}
62204
func (r *RequestConfig) Form(bodyData url.Values) *RequestConfig {
	r.FormData = bodyData
	return r
}
338839
func ParamJson(r *http.Request, name string, v interface{}) error {
	value := r.FormValue(name)
	return json.Unmarshal([]byte(value), v)
}