Skip to content

Commit 075c5ac

Browse files
author
Jamie Tanna
committed
WIP
1 parent 9158b3c commit 075c5ac

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

oapi_validate.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package nethttpmiddleware
55

66
import (
7+
"context"
78
"errors"
89
"fmt"
910
"log"
@@ -17,8 +18,28 @@ import (
1718
)
1819

1920
// ErrorHandler is called when there is an error in validation
21+
//
22+
// NOTE that you likely want to use ErrorHandlerWithOpts, as it provides **??**, and access to the underlying `error`
2023
type ErrorHandler func(w http.ResponseWriter, message string, statusCode int)
2124

25+
// ErrorHandlerWithOpts provides
26+
// NOTE that this should ideally be used instead of ErrorHandler
27+
type ErrorHandlerWithOpts func(ctx context.Context, w http.ResponseWriter, r *http.Request, opts ErrorHandlerOpts)
28+
29+
type ErrorHandlerOpts struct {
30+
// Route indicates the Route that this error is received by, providing full context into the OpenAPI Spec TODO
31+
// TODO
32+
Route *routers.Route
33+
34+
// Error is the underlying error that triggered this error handler to be executed.
35+
Error error
36+
37+
// StatusCode indicates the HTTP Status Code that TODO
38+
//
39+
// NOTE that this is a suggestion, and can be ignored if believed to be TODO
40+
StatusCode int
41+
}
42+
2243
// MultiErrorHandler is called when oapi returns a MultiError type
2344
type MultiErrorHandler func(openapi3.MultiError) (int, error)
2445

0 commit comments

Comments
 (0)