MCPcopy Create free account
hub / github.com/cloudflare/cfssl / ProcessRequestFirstMatchOf

Function ProcessRequestFirstMatchOf

api/api.go:140–152  ·  view source on GitHub ↗

ProcessRequestFirstMatchOf reads a JSON blob for the request and returns the first match of a set of keywords. For example, a request might have one of the following combinations: (foo=1, bar=2), (foo=1), and (bar=2) By giving a specific ordering of those combinations, we could decide how to accept

(r *http.Request, keywordSets [][]string)

Source from the content-addressed store, hash-verified

138// By giving a specific ordering of those combinations, we could decide how to accept
139// the request.
140func ProcessRequestFirstMatchOf(r *http.Request, keywordSets [][]string) (map[string]string, []string, error) {
141 blob, err := readRequestBlob(r)
142 if err != nil {
143 return nil, nil, err
144 }
145
146 for _, set := range keywordSets {
147 if matchKeywords(blob, set) {
148 return blob, set, nil
149 }
150 }
151 return nil, nil, errors.NewBadRequestString("no valid parameter sets found")
152}
153
154func matchKeywords(blob map[string]string, keywords []string) bool {
155 for _, keyword := range keywords {

Callers 3

HandleMethod · 0.92
HandleMethod · 0.92
cleverHandleFunction · 0.85

Calls 3

NewBadRequestStringFunction · 0.92
readRequestBlobFunction · 0.85
matchKeywordsFunction · 0.85

Tested by 1

cleverHandleFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…