aboutsummaryrefslogtreecommitdiff
path: root/args.go
diff options
context:
space:
mode:
authorGravatar Aliaksandr Valialkin <valyala@gmail.com> 2017-01-30 19:47:15 +0200
committerGravatar Aliaksandr Valialkin <valyala@gmail.com> 2017-01-30 19:47:15 +0200
commitb69eba7101fa6c66ba4db0641968a401c9f4f148 (patch)
tree1c175e2b4da5d0b776423c29000525f89fc65de2 /args.go
parentDocument that the cookie passed to ResponseHeader.SetCookie may be re-used af... (diff)
downloadfasthttp-b69eba7101fa6c66ba4db0641968a401c9f4f148.tar.gz
fasthttp-b69eba7101fa6c66ba4db0641968a401c9f4f148.tar.bz2
fasthttp-b69eba7101fa6c66ba4db0641968a401c9f4f148.zip
Added Args.GetBool helper
Diffstat (limited to 'args.go')
-rw-r--r--args.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/args.go b/args.go
index 5098727..951028b 100644
--- a/args.go
+++ b/args.go
@@ -285,6 +285,19 @@ func (a *Args) GetUfloatOrZero(key string) float64 {
return f
}
+// GetBool returns boolean value for the given key.
+//
+// true is returned for '1', 'y' and 'yes' values,
+// otherwise false is returned.
+func (a *Args) GetBool(key string) bool {
+ switch string(a.Peek(key)) {
+ case "1", "y", "yes":
+ return true
+ default:
+ return false
+ }
+}
+
func visitArgs(args []argsKV, f func(k, v []byte)) {
for i, n := 0, len(args); i < n; i++ {
kv := &args[i]