PostValueDefault returns the last parsed form data from POST, PATCH, or PUT body parameters based on a "name". If not found then "def" is returned instead.
(name string, def string)
| 1951 | // |
| 1952 | // If not found then "def" is returned instead. |
| 1953 | func (ctx *Context) PostValueDefault(name string, def string) string { |
| 1954 | values, err := ctx.PostValues(name) |
| 1955 | if err != nil || len(values) == 0 { |
| 1956 | return def // it returns "def" even if it's empty here. |
| 1957 | } |
| 1958 | |
| 1959 | return values[len(values)-1] |
| 1960 | } |
| 1961 | |
| 1962 | // PostValueString same as `PostValue` method but it reports |
| 1963 | // an error if the value with key equals to "name" does not exist. |
no test coverage detected