v0.0.199
This commit is contained in:
parent
0cfa159cb1
commit
adf32568ee
@ -2,6 +2,7 @@ package ginext
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"gogs.mikescher.com/BlackForestBytes/goext/langext"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -12,8 +13,9 @@ var anyMethods = []string{
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GinRoutesWrapper struct {
|
type GinRoutesWrapper struct {
|
||||||
wrapper *GinWrapper
|
wrapper *GinWrapper
|
||||||
routes gin.IRouter
|
routes gin.IRouter
|
||||||
|
defaultHandler []gin.HandlerFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
type GinRouteBuilder struct {
|
type GinRouteBuilder struct {
|
||||||
@ -29,43 +31,49 @@ func (w *GinWrapper) Routes() *GinRoutesWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *GinRoutesWrapper) Group(relativePath string) *GinRoutesWrapper {
|
func (w *GinRoutesWrapper) Group(relativePath string) *GinRoutesWrapper {
|
||||||
return &GinRoutesWrapper{wrapper: w.wrapper, routes: w.routes.Group(relativePath)}
|
return &GinRoutesWrapper{wrapper: w.wrapper, routes: w.routes.Group(relativePath), defaultHandler: langext.ArrCopy(w.defaultHandler)}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *GinRoutesWrapper) Use(middleware ...gin.HandlerFunc) *GinRoutesWrapper {
|
||||||
|
defHandler := langext.ArrCopy(w.defaultHandler)
|
||||||
|
defHandler = append(defHandler, middleware...)
|
||||||
|
return &GinRoutesWrapper{wrapper: w.wrapper, routes: w.routes, defaultHandler: defHandler}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *GinRoutesWrapper) GET(relativePath string) *GinRouteBuilder {
|
func (w *GinRoutesWrapper) GET(relativePath string) *GinRouteBuilder {
|
||||||
return &GinRouteBuilder{routes: w, methods: []string{http.MethodGet}, relPath: relativePath, handlers: make([]gin.HandlerFunc, 0)}
|
return &GinRouteBuilder{routes: w, methods: []string{http.MethodGet}, relPath: relativePath, handlers: langext.ArrCopy(w.defaultHandler)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *GinRoutesWrapper) POST(relativePath string) *GinRouteBuilder {
|
func (w *GinRoutesWrapper) POST(relativePath string) *GinRouteBuilder {
|
||||||
return &GinRouteBuilder{routes: w, methods: []string{http.MethodPost}, relPath: relativePath, handlers: make([]gin.HandlerFunc, 0)}
|
return &GinRouteBuilder{routes: w, methods: []string{http.MethodPost}, relPath: relativePath, handlers: langext.ArrCopy(w.defaultHandler)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *GinRoutesWrapper) DELETE(relativePath string) *GinRouteBuilder {
|
func (w *GinRoutesWrapper) DELETE(relativePath string) *GinRouteBuilder {
|
||||||
return &GinRouteBuilder{routes: w, methods: []string{http.MethodDelete}, relPath: relativePath, handlers: make([]gin.HandlerFunc, 0)}
|
return &GinRouteBuilder{routes: w, methods: []string{http.MethodDelete}, relPath: relativePath, handlers: langext.ArrCopy(w.defaultHandler)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *GinRoutesWrapper) PATCH(relativePath string) *GinRouteBuilder {
|
func (w *GinRoutesWrapper) PATCH(relativePath string) *GinRouteBuilder {
|
||||||
return &GinRouteBuilder{routes: w, methods: []string{http.MethodPatch}, relPath: relativePath, handlers: make([]gin.HandlerFunc, 0)}
|
return &GinRouteBuilder{routes: w, methods: []string{http.MethodPatch}, relPath: relativePath, handlers: langext.ArrCopy(w.defaultHandler)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *GinRoutesWrapper) PUT(relativePath string) *GinRouteBuilder {
|
func (w *GinRoutesWrapper) PUT(relativePath string) *GinRouteBuilder {
|
||||||
return &GinRouteBuilder{routes: w, methods: []string{http.MethodPut}, relPath: relativePath, handlers: make([]gin.HandlerFunc, 0)}
|
return &GinRouteBuilder{routes: w, methods: []string{http.MethodPut}, relPath: relativePath, handlers: langext.ArrCopy(w.defaultHandler)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *GinRoutesWrapper) OPTIONS(relativePath string) *GinRouteBuilder {
|
func (w *GinRoutesWrapper) OPTIONS(relativePath string) *GinRouteBuilder {
|
||||||
return &GinRouteBuilder{routes: w, methods: []string{http.MethodOptions}, relPath: relativePath, handlers: make([]gin.HandlerFunc, 0)}
|
return &GinRouteBuilder{routes: w, methods: []string{http.MethodOptions}, relPath: relativePath, handlers: langext.ArrCopy(w.defaultHandler)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *GinRoutesWrapper) HEAD(relativePath string) *GinRouteBuilder {
|
func (w *GinRoutesWrapper) HEAD(relativePath string) *GinRouteBuilder {
|
||||||
return &GinRouteBuilder{routes: w, methods: []string{http.MethodHead}, relPath: relativePath, handlers: make([]gin.HandlerFunc, 0)}
|
return &GinRouteBuilder{routes: w, methods: []string{http.MethodHead}, relPath: relativePath, handlers: langext.ArrCopy(w.defaultHandler)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *GinRoutesWrapper) COUNT(relativePath string) *GinRouteBuilder {
|
func (w *GinRoutesWrapper) COUNT(relativePath string) *GinRouteBuilder {
|
||||||
return &GinRouteBuilder{routes: w, methods: []string{"COUNT"}, relPath: relativePath, handlers: make([]gin.HandlerFunc, 0)}
|
return &GinRouteBuilder{routes: w, methods: []string{"COUNT"}, relPath: relativePath, handlers: langext.ArrCopy(w.defaultHandler)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *GinRoutesWrapper) Any(relativePath string) *GinRouteBuilder {
|
func (w *GinRoutesWrapper) Any(relativePath string) *GinRouteBuilder {
|
||||||
return &GinRouteBuilder{routes: w, methods: anyMethods, relPath: relativePath, handlers: make([]gin.HandlerFunc, 0)}
|
return &GinRouteBuilder{routes: w, methods: anyMethods, relPath: relativePath, handlers: langext.ArrCopy(w.defaultHandler)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *GinRouteBuilder) Use(middleware ...gin.HandlerFunc) *GinRouteBuilder {
|
func (w *GinRouteBuilder) Use(middleware ...gin.HandlerFunc) *GinRouteBuilder {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
package goext
|
package goext
|
||||||
|
|
||||||
const GoextVersion = "0.0.198"
|
const GoextVersion = "0.0.199"
|
||||||
|
|
||||||
const GoextVersionTimestamp = "2023-07-24T14:16:02+0200"
|
const GoextVersionTimestamp = "2023-07-24T17:23:38+0200"
|
||||||
|
Loading…
Reference in New Issue
Block a user