forked from loafle/openapi-generator-original
add a new function router to pass gin context (#17785)
This commit is contained in:
parent
7cdbb2a7b4
commit
fdb001c8a3
@ -21,7 +21,11 @@ type Route struct {
|
|||||||
|
|
||||||
// NewRouter returns a new router.
|
// NewRouter returns a new router.
|
||||||
func NewRouter(handleFunctions ApiHandleFunctions) *gin.Engine {
|
func NewRouter(handleFunctions ApiHandleFunctions) *gin.Engine {
|
||||||
router := gin.Default()
|
return NewRouterWithGinEngine(gin.Default(), handleFunctions)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewRouter add routes to existing gin engine.
|
||||||
|
func NewRouterWithGinEngine(router *gin.Engine, handleFunctions ApiHandleFunctions) *gin.Engine {
|
||||||
for _, route := range getRoutes(handleFunctions) {
|
for _, route := range getRoutes(handleFunctions) {
|
||||||
if route.HandlerFunc == nil {
|
if route.HandlerFunc == nil {
|
||||||
route.HandlerFunc = DefaultHandleFunc
|
route.HandlerFunc = DefaultHandleFunc
|
||||||
|
@ -29,7 +29,11 @@ type Route struct {
|
|||||||
|
|
||||||
// NewRouter returns a new router.
|
// NewRouter returns a new router.
|
||||||
func NewRouter(handleFunctions ApiHandleFunctions) *gin.Engine {
|
func NewRouter(handleFunctions ApiHandleFunctions) *gin.Engine {
|
||||||
router := gin.Default()
|
return NewRouterWithGinEngine(gin.Default(), handleFunctions)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewRouter add routes to existing gin engine.
|
||||||
|
func NewRouterWithGinEngine(router *gin.Engine, handleFunctions ApiHandleFunctions) *gin.Engine {
|
||||||
for _, route := range getRoutes(handleFunctions) {
|
for _, route := range getRoutes(handleFunctions) {
|
||||||
if route.HandlerFunc == nil {
|
if route.HandlerFunc == nil {
|
||||||
route.HandlerFunc = DefaultHandleFunc
|
route.HandlerFunc = DefaultHandleFunc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user