GenericErrorFn is a reusable method for the middleware layers that they can use to get well structured JSON output for BasicErrorModel.
(ctx context.Context, statusCode int, w http.ResponseWriter, err error)
| 312 | } |
| 313 | |
| 314 | return createOpenAPIServerServer(port, srv, preRequestValidationMiddlewares, authMiddleware) |
| 315 | } |
| 316 | |
| 317 | func createOpenAPIServerServer( |
| 318 | port string, |
| 319 | srv backend.StrictServerInterface, |
| 320 | preRequestValidationMiddlewares []func(http.Handler) http.Handler, |
| 321 | authMiddleware func(http.Handler) http.Handler) *http.Server { |
| 322 | |
| 323 | srvStrictHandler := backend.NewStrictHandler(srv, |
| 324 | wrapPostRequestValidationMiddlewaresForOpenAPIHook(authMiddleware)) |
| 325 | |
| 326 | // Use standard library router |
| 327 | r := http.NewServeMux() |
| 328 | |
| 329 | // We now register our web feature router above as the handler for the interface |
| 330 | backend.HandlerFromMux(srvStrictHandler, r) |
| 331 | |
| 332 | // Now wrap the middlewares |
| 333 | wrappedHandler := applyPreRequestValidationMiddlewares(r, preRequestValidationMiddlewares) |