Added support for using cosmosdb-explorer

This commit is contained in:
Pijus Kamandulis
2024-02-14 01:47:51 +02:00
parent b780e8c228
commit 31eaf0ad3f
5 changed files with 68 additions and 6 deletions

29
api/handlers/explorer.go Normal file
View File

@@ -0,0 +1,29 @@
package handlers
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/pikami/cosmium/api/config"
)
func RegisterExplorerHandlers(router *gin.Engine) {
explorer := router.Group("/_explorer")
{
explorer.Use(func(ctx *gin.Context) {
if ctx.Param("filepath") == "/config.json" {
endpoint := fmt.Sprintf("https://%s:%d", config.Config.Host, config.Config.Port)
ctx.JSON(200, gin.H{
"BACKEND_ENDPOINT": endpoint,
"MONGO_BACKEND_ENDPOINT": endpoint,
"PROXY_PATH": "/",
"EMULATOR_ENDPOINT": endpoint,
})
ctx.Abort()
} else {
ctx.Next()
}
})
explorer.Static("/", config.Config.ExplorerPath)
}
}