v0.0.484
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m58s
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m58s
This commit is contained in:
@@ -27,6 +27,8 @@ type GinWrapper struct {
|
||||
listenerBeforeRequest []func(g *gin.Context)
|
||||
listenerAfterRequest []func(g *gin.Context, resp HTTPResponse)
|
||||
|
||||
buildRequestBindError func(g *gin.Context, fieldtype string, err error) HTTPResponse
|
||||
|
||||
routeSpecs []ginRouteSpec
|
||||
}
|
||||
|
||||
@@ -38,15 +40,16 @@ type ginRouteSpec struct {
|
||||
}
|
||||
|
||||
type Options struct {
|
||||
AllowCors *bool // Add cors handler to allow all CORS requests on the default http methods
|
||||
GinDebug *bool // Set gin.debug to true (adds more logs)
|
||||
SuppressGinLogs *bool // Suppress our custom gin logs (even if GinDebug == true)
|
||||
BufferBody *bool // Buffers the input body stream, this way the ginext error handler can later include the whole request body
|
||||
Timeout *time.Duration // The default handler timeout
|
||||
ListenerBeforeRequest []func(g *gin.Context) // Register listener that are called before the handler method
|
||||
ListenerAfterRequest []func(g *gin.Context, resp HTTPResponse) // Register listener that are called after the handler method
|
||||
DebugTrimHandlerPrefixes []string // Trim these prefixes from the handler names in the debug print
|
||||
DebugReplaceHandlerNames map[string]string // Replace handler names in debug output
|
||||
AllowCors *bool // Add cors handler to allow all CORS requests on the default http methods
|
||||
GinDebug *bool // Set gin.debug to true (adds more logs)
|
||||
SuppressGinLogs *bool // Suppress our custom gin logs (even if GinDebug == true)
|
||||
BufferBody *bool // Buffers the input body stream, this way the ginext error handler can later include the whole request body
|
||||
Timeout *time.Duration // The default handler timeout
|
||||
ListenerBeforeRequest []func(g *gin.Context) // Register listener that are called before the handler method
|
||||
ListenerAfterRequest []func(g *gin.Context, resp HTTPResponse) // Register listener that are called after the handler method
|
||||
DebugTrimHandlerPrefixes []string // Trim these prefixes from the handler names in the debug print
|
||||
DebugReplaceHandlerNames map[string]string // Replace handler names in debug output
|
||||
BuildRequestBindError func(g *gin.Context, fieldtype string, err error) HTTPResponse // Override function which generates the HTTPResponse errors that are returned by the preContext..Start() methids
|
||||
}
|
||||
|
||||
// NewEngine creates a new (wrapped) ginEngine
|
||||
@@ -77,6 +80,7 @@ func NewEngine(opt Options) *GinWrapper {
|
||||
requestTimeout: langext.Coalesce(opt.Timeout, 24*time.Hour),
|
||||
listenerBeforeRequest: opt.ListenerBeforeRequest,
|
||||
listenerAfterRequest: opt.ListenerAfterRequest,
|
||||
buildRequestBindError: langext.Conditional(opt.BuildRequestBindError == nil, defaultBuildRequestBindError, opt.BuildRequestBindError),
|
||||
}
|
||||
|
||||
engine.RedirectFixedPath = false
|
||||
@@ -222,3 +226,7 @@ func (w *GinWrapper) ForwardRequest(writer http.ResponseWriter, req *http.Reques
|
||||
func (w *GinWrapper) ListRoutes() []gin.RouteInfo {
|
||||
return w.engine.Routes()
|
||||
}
|
||||
|
||||
func defaultBuildRequestBindError(g *gin.Context, fieldtype string, err error) HTTPResponse {
|
||||
return Error(err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user