Add ability to launch pgweb with url prefix
This commit is contained in:
@@ -2,6 +2,7 @@ package api
|
||||
|
||||
import (
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
@@ -12,7 +13,9 @@ import (
|
||||
// Middleware function to check database connection status before running queries
|
||||
func dbCheckMiddleware() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
if allowedPaths[c.Request.URL.Path] == true {
|
||||
path := strings.Replace(c.Request.URL.Path, command.Opts.Prefix, "", -1)
|
||||
|
||||
if allowedPaths[path] == true {
|
||||
c.Next()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -14,10 +14,12 @@ func SetupMiddlewares(group *gin.RouterGroup) {
|
||||
}
|
||||
|
||||
func SetupRoutes(router *gin.Engine) {
|
||||
router.GET("/", GetHome)
|
||||
router.GET("/static/*path", GetAsset)
|
||||
group := router.Group(command.Opts.Prefix)
|
||||
|
||||
api := router.Group("/api")
|
||||
group.GET("/", GetHome)
|
||||
group.GET("/static/*path", GetAsset)
|
||||
|
||||
api := group.Group("/api")
|
||||
{
|
||||
SetupMiddlewares(api)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user