Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
617298c366
|
|||
668f308565 |
@@ -9,6 +9,7 @@ import (
|
|||||||
"gogs.mikescher.com/BlackForestBytes/goext/rext"
|
"gogs.mikescher.com/BlackForestBytes/goext/rext"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -16,7 +17,7 @@ import (
|
|||||||
|
|
||||||
type GinWrapper struct {
|
type GinWrapper struct {
|
||||||
engine *gin.Engine
|
engine *gin.Engine
|
||||||
SuppressGinLogs bool
|
suppressGinLogs bool
|
||||||
|
|
||||||
allowCors bool
|
allowCors bool
|
||||||
ginDebug bool
|
ginDebug bool
|
||||||
@@ -50,7 +51,7 @@ func NewEngine(opt Options) *GinWrapper {
|
|||||||
|
|
||||||
wrapper := &GinWrapper{
|
wrapper := &GinWrapper{
|
||||||
engine: engine,
|
engine: engine,
|
||||||
SuppressGinLogs: false,
|
suppressGinLogs: false,
|
||||||
allowCors: langext.Coalesce(opt.AllowCors, false),
|
allowCors: langext.Coalesce(opt.AllowCors, false),
|
||||||
ginDebug: langext.Coalesce(opt.GinDebug, true),
|
ginDebug: langext.Coalesce(opt.GinDebug, true),
|
||||||
bufferBody: langext.Coalesce(opt.BufferBody, false),
|
bufferBody: langext.Coalesce(opt.BufferBody, false),
|
||||||
@@ -74,7 +75,7 @@ func NewEngine(opt Options) *GinWrapper {
|
|||||||
|
|
||||||
ginlogger := gin.Logger()
|
ginlogger := gin.Logger()
|
||||||
engine.Use(func(context *gin.Context) {
|
engine.Use(func(context *gin.Context) {
|
||||||
if !wrapper.SuppressGinLogs {
|
if !wrapper.suppressGinLogs {
|
||||||
ginlogger(context)
|
ginlogger(context)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -185,3 +186,10 @@ func (w *GinWrapper) cleanMiddlewareName(fname string) string {
|
|||||||
|
|
||||||
return fname
|
return fname
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ServeHTTP only used for unit tests
|
||||||
|
func (w *GinWrapper) ServeHTTP(req *http.Request) *httptest.ResponseRecorder {
|
||||||
|
respRec := httptest.NewRecorder()
|
||||||
|
w.engine.ServeHTTP(respRec, req)
|
||||||
|
return respRec
|
||||||
|
}
|
||||||
|
1
go.sum
1
go.sum
@@ -36,6 +36,7 @@ github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LB
|
|||||||
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
||||||
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||||
|
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||||
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||||
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
|
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
|
||||||
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
package goext
|
package goext
|
||||||
|
|
||||||
const GoextVersion = "0.0.363"
|
const GoextVersion = "0.0.365"
|
||||||
|
|
||||||
const GoextVersionTimestamp = "2024-01-09T08:51:46+0100"
|
const GoextVersionTimestamp = "2024-01-09T18:23:46+0100"
|
||||||
|
Reference in New Issue
Block a user