summaryrefslogtreecommitdiff
path: root/vendor/github.com/go-openapi/runtime/middleware/validation.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2024-04-26 11:31:10 +0200
committerLibravatar GitHub <noreply@github.com>2024-04-26 11:31:10 +0200
commitfd8a724e77123d5035d4070581dab777b4533ebb (patch)
tree0d3d20ad5c7c2177d970ead12f5108d1d3666623 /vendor/github.com/go-openapi/runtime/middleware/validation.go
parent[chore] Upgrade our Go version to 1.22 (#2862) (diff)
downloadgotosocial-fd8a724e77123d5035d4070581dab777b4533ebb.tar.xz
[chore] Bump go swagger (#2871)
* bump go swagger version * bump swagger version
Diffstat (limited to 'vendor/github.com/go-openapi/runtime/middleware/validation.go')
-rw-r--r--vendor/github.com/go-openapi/runtime/middleware/validation.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/vendor/github.com/go-openapi/runtime/middleware/validation.go b/vendor/github.com/go-openapi/runtime/middleware/validation.go
index 1f0135b57..0a5356c60 100644
--- a/vendor/github.com/go-openapi/runtime/middleware/validation.go
+++ b/vendor/github.com/go-openapi/runtime/middleware/validation.go
@@ -35,7 +35,6 @@ type validation struct {
// ContentType validates the content type of a request
func validateContentType(allowed []string, actual string) error {
- debugLog("validating content type for %q against [%s]", actual, strings.Join(allowed, ", "))
if len(allowed) == 0 {
return nil
}
@@ -57,13 +56,13 @@ func validateContentType(allowed []string, actual string) error {
}
func validateRequest(ctx *Context, request *http.Request, route *MatchedRoute) *validation {
- debugLog("validating request %s %s", request.Method, request.URL.EscapedPath())
validate := &validation{
context: ctx,
request: request,
route: route,
bound: make(map[string]interface{}),
}
+ validate.debugLogf("validating request %s %s", request.Method, request.URL.EscapedPath())
validate.contentType()
if len(validate.result) == 0 {
@@ -76,8 +75,12 @@ func validateRequest(ctx *Context, request *http.Request, route *MatchedRoute) *
return validate
}
+func (v *validation) debugLogf(format string, args ...any) {
+ v.context.debugLogf(format, args...)
+}
+
func (v *validation) parameters() {
- debugLog("validating request parameters for %s %s", v.request.Method, v.request.URL.EscapedPath())
+ v.debugLogf("validating request parameters for %s %s", v.request.Method, v.request.URL.EscapedPath())
if result := v.route.Binder.Bind(v.request, v.route.Params, v.route.Consumer, v.bound); result != nil {
if result.Error() == "validation failure list" {
for _, e := range result.(*errors.Validation).Value.([]interface{}) {
@@ -91,7 +94,7 @@ func (v *validation) parameters() {
func (v *validation) contentType() {
if len(v.result) == 0 && runtime.HasBody(v.request) {
- debugLog("validating body content type for %s %s", v.request.Method, v.request.URL.EscapedPath())
+ v.debugLogf("validating body content type for %s %s", v.request.Method, v.request.URL.EscapedPath())
ct, _, req, err := v.context.ContentType(v.request)
if err != nil {
v.result = append(v.result, err)
@@ -100,6 +103,7 @@ func (v *validation) contentType() {
}
if len(v.result) == 0 {
+ v.debugLogf("validating content type for %q against [%s]", ct, strings.Join(v.route.Consumes, ", "))
if err := validateContentType(v.route.Consumes, ct); err != nil {
v.result = append(v.result, err)
}