Manager: register OpenAPI body decoders for image mime types
The OpenAPI library we use for request validation needs to know per mime type how to handle the contents. The same function for `application/octet-stream` is now used for `image/png` and `image/jpeg` as well.
This commit is contained in:
parent
167b2eaf45
commit
a43826ce0c
@ -20,6 +20,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/benbjohnson/clock"
|
"github.com/benbjohnson/clock"
|
||||||
|
"github.com/getkin/kin-openapi/openapi3filter"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"github.com/labstack/echo/v4/middleware"
|
"github.com/labstack/echo/v4/middleware"
|
||||||
"github.com/mattn/go-colorable"
|
"github.com/mattn/go-colorable"
|
||||||
@ -258,6 +259,7 @@ func buildWebService(
|
|||||||
}
|
}
|
||||||
validator := api_impl.SwaggerValidator(swagger, persist)
|
validator := api_impl.SwaggerValidator(swagger, persist)
|
||||||
e.Use(validator)
|
e.Use(validator)
|
||||||
|
registerOAPIBodyDecoders()
|
||||||
|
|
||||||
// Register routes.
|
// Register routes.
|
||||||
api.RegisterHandlers(e, flamenco)
|
api.RegisterHandlers(e, flamenco)
|
||||||
@ -444,3 +446,10 @@ func randomDelayMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func registerOAPIBodyDecoders() {
|
||||||
|
// Register "decoders" so that binary data other than
|
||||||
|
// "application/octet-stream" can be handled by our OpenAPI library.
|
||||||
|
openapi3filter.RegisterBodyDecoder("image/jpeg", openapi3filter.FileBodyDecoder)
|
||||||
|
openapi3filter.RegisterBodyDecoder("image/png", openapi3filter.FileBodyDecoder)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user