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

Function ProcessRequestOneOf

api/api.go:114–133  ·  view source on GitHub ↗

ProcessRequestOneOf reads a JSON blob for the request and makes sure it contains one of a set of keywords. For example, a request might have the ('foo' && 'bar') keys, OR it might have the 'baz' key. In either case, we want to accept the request; however, if none of these sets shows up, the request

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

Source from the content-addressed store, hash-verified

112// none of these sets shows up, the request is a bad request, and it
113// should be returned.
114func ProcessRequestOneOf(r *http.Request, keywordSets [][]string) (map[string]string, []string, error) {
115 blob, err := readRequestBlob(r)
116 if err != nil {
117 return nil, nil, err
118 }
119
120 var matched []string
121 for _, set := range keywordSets {
122 if matchKeywords(blob, set) {
123 if matched != nil {
124 return nil, nil, errors.NewBadRequestString("mismatched parameters")
125 }
126 matched = set
127 }
128 }
129 if matched == nil {
130 return nil, nil, errors.NewBadRequestString("no valid parameter sets found")
131 }
132 return blob, matched, nil
133}
134
135// ProcessRequestFirstMatchOf reads a JSON blob for the request and returns
136// the first match of a set of keywords. For example, a request

Callers 1

simpleHandleFunction · 0.85

Calls 3

NewBadRequestStringFunction · 0.92
readRequestBlobFunction · 0.85
matchKeywordsFunction · 0.85

Tested by 1

simpleHandleFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…