MCPcopy Create free account
hub / github.com/GoogleChrome/webstatus.dev / GenericErrorFn

Function GenericErrorFn

backend/pkg/httpserver/server.go:314–330  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

312 }
313
314 return createOpenAPIServerServer(port, srv, preRequestValidationMiddlewares, authMiddleware)
315}
316
317func 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)

Callers 1

TestGenericErrorFnFunction · 0.85

Calls 1

ErrorMethod · 0.45

Tested by 1

TestGenericErrorFnFunction · 0.68