MCPcopy
hub / github.com/labstack/echo / valuesFromParam

Function valuesFromParam

middleware/extractor.go:180–202  ·  view source on GitHub ↗

valuesFromParam returns a function that extracts values from the url param string.

(param string, limit uint)

Source from the content-addressed store, hash-verified

178
179// valuesFromParam returns a function that extracts values from the url param string.
180func 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.
205func valuesFromCookie(name string, limit uint) ValuesExtractor {

Callers 2

createExtractorsFunction · 0.85
TestValuesFromParamFunction · 0.85

Calls 1

PathValuesMethod · 0.80

Tested by 1

TestValuesFromParamFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…