valuesFromParam returns a function that extracts values from the url param string.
(param string, limit uint)
| 178 | |
| 179 | // valuesFromParam returns a function that extracts values from the url param string. |
| 180 | func valuesFromParam(param string, limit uint) ValuesExtractor { |
| 181 | if limit == 0 { |
| 182 | limit = 1 |
| 183 | } |
| 184 | return func(c *echo.Context) ([]string, ExtractorSource, error) { |
| 185 | result := make([]string, 0) |
| 186 | i := uint(0) |
| 187 | for _, p := range c.PathValues() { |
| 188 | if param != p.Name { |
| 189 | continue |
| 190 | } |
| 191 | result = append(result, p.Value) |
| 192 | i++ |
| 193 | if i >= limit { |
| 194 | break |
| 195 | } |
| 196 | } |
| 197 | if len(result) == 0 { |
| 198 | return nil, ExtractorSourcePathParam, errParamExtractorValueMissing |
| 199 | } |
| 200 | return result, ExtractorSourcePathParam, nil |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | // valuesFromCookie returns a function that extracts values from the named cookie. |
| 205 | func valuesFromCookie(name string, limit uint) ValuesExtractor { |
searching dependent graphs…