Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
e19cb30713
|
|||
|
90dc6079d5
|
@@ -104,3 +104,17 @@ func WrapHTTPHandlerFunc(w *GinWrapper, fn http.HandlerFunc) gin.HandlerFunc {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func WrapExtHTTPHandlerFunc(w *GinWrapper, fn func(*gin.Context, http.ResponseWriter, *http.Request)) gin.HandlerFunc {
|
||||
return func(g *gin.Context) {
|
||||
for _, lstr := range w.listenerBeforeRequest {
|
||||
lstr(g)
|
||||
}
|
||||
|
||||
fn(g, g.Writer, g.Request)
|
||||
|
||||
for _, lstr := range w.listenerAfterRequest {
|
||||
lstr(g, nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+34
-2
@@ -1,13 +1,14 @@
|
||||
package ginext
|
||||
|
||||
import (
|
||||
"git.blackforestbytes.com/BlackForestBytes/goext/langext"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"path"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"git.blackforestbytes.com/BlackForestBytes/goext/langext"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var anyMethods = []string{
|
||||
@@ -210,6 +211,37 @@ func (w *GinRouteBuilder) HandleRawHTTPHandlerFunc(f http.HandlerFunc) {
|
||||
})
|
||||
}
|
||||
|
||||
func (w *GinRouteBuilder) HandleExtHTTPHandlerFunc(f func(*gin.Context, http.ResponseWriter, *http.Request)) {
|
||||
if w.routes.wrapper.bufferBody {
|
||||
arr := make([]gin.HandlerFunc, 0, len(w.handlers)+1)
|
||||
arr = append(arr, BodyBuffer)
|
||||
arr = append(arr, w.handlers...)
|
||||
w.handlers = arr
|
||||
}
|
||||
|
||||
middlewareNames := langext.ArrMap(w.handlers, func(v gin.HandlerFunc) string { return nameOfFunction(v) })
|
||||
|
||||
w.handlers = append(w.handlers, WrapExtHTTPHandlerFunc(w.routes.wrapper, f))
|
||||
|
||||
methodName := w.method
|
||||
|
||||
if w.method == "*" {
|
||||
methodName = "ANY"
|
||||
for _, method := range anyMethods {
|
||||
w.routes.routes.Handle(method, w.relPath, w.handlers...)
|
||||
}
|
||||
} else {
|
||||
w.routes.routes.Handle(w.method, w.relPath, w.handlers...)
|
||||
}
|
||||
|
||||
w.routes.wrapper.routeSpecs = append(w.routes.wrapper.routeSpecs, ginRouteSpec{
|
||||
Method: methodName,
|
||||
URL: w.absPath,
|
||||
Middlewares: middlewareNames,
|
||||
Handler: "[HTTPHandlerFunc]",
|
||||
})
|
||||
}
|
||||
|
||||
func (w *GinWrapper) NoRoute(handler WHandlerFunc) {
|
||||
|
||||
handlers := make([]gin.HandlerFunc, 0)
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
package goext
|
||||
|
||||
const GoextVersion = "0.0.626"
|
||||
const GoextVersion = "0.0.628"
|
||||
|
||||
const GoextVersionTimestamp = "2026-03-14T00:50:15+0100"
|
||||
const GoextVersionTimestamp = "2026-03-14T01:13:37+0100"
|
||||
|
||||
Reference in New Issue
Block a user