added: exclude routes
This commit is contained in:
parent
0a53ac2974
commit
2028671a54
2 changed files with 11 additions and 1 deletions
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"merch-parser-api/internal/interfaces"
|
"merch-parser-api/internal/interfaces"
|
||||||
|
"merch-parser-api/internal/shared"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
@ -40,12 +41,17 @@ func NewApp(deps Deps) *App {
|
||||||
c.String(http.StatusOK, "API is ready")
|
c.String(http.StatusOK, "API is ready")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
var excludeRoutes []shared.ExcludeRoute
|
||||||
|
|
||||||
for _, m := range app.modules {
|
for _, m := range app.modules {
|
||||||
if hasRoutes, ok := m.(interfaces.ModuleRoutes); ok {
|
if hasRoutes, ok := m.(interfaces.ModuleRoutes); ok {
|
||||||
hasRoutes.RegisterRoutes(apiRoutes)
|
hasRoutes.RegisterRoutes(apiRoutes)
|
||||||
|
excludeRoutes = append(excludeRoutes, hasRoutes.ExcludeRoutes()...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.routerHandler.ExcludeRoutes(excludeRoutes)
|
||||||
|
|
||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
package interfaces
|
package interfaces
|
||||||
|
|
||||||
import "github.com/gin-gonic/gin"
|
import (
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"merch-parser-api/internal/shared"
|
||||||
|
)
|
||||||
|
|
||||||
type Router interface {
|
type Router interface {
|
||||||
Set() *gin.Engine
|
Set() *gin.Engine
|
||||||
|
ExcludeRoutes(routes []shared.ExcludeRoute)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue