parseBool reads the value for given URL parameter from request and parses it into bool, empty string is converted into zero value
(r *http.Request, name string)
| 105 | // parseBool reads the value for given URL parameter from request and |
| 106 | // parses it into bool, empty string is converted into zero value |
| 107 | func parseBool(r *http.Request, name string) (bool, error) { |
| 108 | value := r.URL.Query().Get(name) |
| 109 | if value == "" { |
| 110 | return false, nil |
| 111 | } |
| 112 | |
| 113 | boolval, err := strconv.ParseBool(value) |
| 114 | if err != nil { |
| 115 | return false, errors.Wrapf(err, "while parsing %s as bool", name) |
| 116 | } |
| 117 | |
| 118 | return boolval, nil |
| 119 | } |
| 120 | |
| 121 | // parseDuration reads the value for given URL parameter from request and |
| 122 | // parses it into time.Duration, empty string is converted into zero value |
no test coverage detected