Files
docker-cli/components/engine/api/server/form.go
Adria Casas 3f873c25b6 Rename int64Value to int64ValueOrZero.
Signed-off-by: Adria Casas <adriacasas88@gmail.com>
Upstream-commit: a2c76912e04b087233577b46f96f446c5d13e2de
Component: engine
2015-05-05 08:54:28 +02:00

21 lines
402 B
Go

package server
import (
"net/http"
"strconv"
"strings"
)
func boolValue(r *http.Request, k string) bool {
s := strings.ToLower(strings.TrimSpace(r.FormValue(k)))
return !(s == "" || s == "0" || s == "no" || s == "false" || s == "none")
}
func int64ValueOrZero(r *http.Request, k string) int64 {
val, err := strconv.ParseInt(r.FormValue(k), 10, 64)
if err != nil {
return 0
}
return val
}