...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package index
20
21
22
23
24 import (
25 "io"
26 "net/http"
27
28 "github.com/go-openapi/errors"
29 "github.com/go-openapi/runtime"
30 "github.com/go-openapi/runtime/middleware"
31 "github.com/go-openapi/validate"
32
33 "github.com/sigstore/rekor/pkg/generated/models"
34 )
35
36
37
38
39 func NewSearchIndexParams() SearchIndexParams {
40
41 return SearchIndexParams{}
42 }
43
44
45
46
47
48 type SearchIndexParams struct {
49
50
51 HTTPRequest *http.Request `json:"-"`
52
53
57 Query *models.SearchIndex
58 }
59
60
61
62
63
64 func (o *SearchIndexParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
65 var res []error
66
67 o.HTTPRequest = r
68
69 if runtime.HasBody(r) {
70 defer r.Body.Close()
71 var body models.SearchIndex
72 if err := route.Consumer.Consume(r.Body, &body); err != nil {
73 if err == io.EOF {
74 res = append(res, errors.Required("query", "body", ""))
75 } else {
76 res = append(res, errors.NewParseError("query", "body", "", err))
77 }
78 } else {
79
80 if err := body.Validate(route.Formats); err != nil {
81 res = append(res, err)
82 }
83
84 ctx := validate.WithOperationRequest(r.Context())
85 if err := body.ContextValidate(ctx, route.Formats); err != nil {
86 res = append(res, err)
87 }
88
89 if len(res) == 0 {
90 o.Query = &body
91 }
92 }
93 } else {
94 res = append(res, errors.Required("query", "body", ""))
95 }
96 if len(res) > 0 {
97 return errors.CompositeValidationError(res...)
98 }
99 return nil
100 }
101
View as plain text