TRA-4263 extensibility refactor (#770)

* Refactor routers

* refactor extension loading

* refactor server creation code

* Update main.go
This commit is contained in:
RamiBerm
2022-02-08 14:59:56 +02:00
committed by GitHub
parent f013b0f03c
commit 0a4674ea7c
13 changed files with 450 additions and 307 deletions

View File

@@ -7,11 +7,18 @@ import (
"github.com/gin-gonic/gin"
)
var (
EntriesGetHandler = controllers.GetEntries
EntriesGetSingleHandler = controllers.GetEntry
)
// EntriesRoutes defines the group of har entries routes.
func EntriesRoutes(ginApp *gin.Engine) {
func EntriesRoutes(ginApp *gin.Engine) *gin.RouterGroup {
routeGroup := ginApp.Group("/entries")
routeGroup.Use(middlewares.RequiresAuth())
routeGroup.GET("/", controllers.GetEntries) // get entries (base/thin entries) and metadata
routeGroup.GET("/:id", controllers.GetEntry) // get single (full) entry
routeGroup.GET("/", func(c *gin.Context) { EntriesGetHandler(c) }) // get entries (base/thin entries) and metadata
routeGroup.GET("/:id", func(c *gin.Context) { EntriesGetSingleHandler(c) }) // get single (full) entry
return routeGroup
}