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

Function createExtractors

middleware/extractor.go:78–114  ·  view source on GitHub ↗
(lookups string, limit uint)

Source from the content-addressed store, hash-verified

76}
77
78func createExtractors(lookups string, limit uint) ([]ValuesExtractor, error) {
79 if lookups == "" {
80 return nil, nil
81 }
82 if limit == 0 {
83 limit = 1
84 } else if limit > extractorLimit {
85 limit = extractorLimit
86 }
87
88 sources := strings.SplitSeq(lookups, ",")
89 var extractors = make([]ValuesExtractor, 0)
90 for source := range sources {
91 parts := strings.Split(source, ":")
92 if len(parts) < 2 {
93 return nil, fmt.Errorf("extractor source for lookup could not be split into needed parts: %v", source)
94 }
95
96 switch parts[0] {
97 case "query":
98 extractors = append(extractors, valuesFromQuery(parts[1], limit))
99 case "param":
100 extractors = append(extractors, valuesFromParam(parts[1], limit))
101 case "cookie":
102 extractors = append(extractors, valuesFromCookie(parts[1], limit))
103 case "form":
104 extractors = append(extractors, valuesFromForm(parts[1], limit))
105 case "header":
106 prefix := ""
107 if len(parts) > 2 {
108 prefix = parts[2]
109 }
110 extractors = append(extractors, valuesFromHeader(parts[1], prefix, limit))
111 }
112 }
113 return extractors, nil
114}
115
116// valuesFromHeader returns a functions that extracts values from the request header.
117// valuePrefix is parameter to remove first part (prefix) of the extracted value. This is useful if header value has static

Callers 3

CreateExtractorsFunction · 0.85
ToMiddlewareMethod · 0.85
ToMiddlewareMethod · 0.85

Calls 5

valuesFromQueryFunction · 0.85
valuesFromParamFunction · 0.85
valuesFromCookieFunction · 0.85
valuesFromFormFunction · 0.85
valuesFromHeaderFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…