mirror of
https://github.com/pikami/cosmium.git
synced 2025-12-19 00:40:47 +00:00
Added support for using cosmosdb-explorer
This commit is contained in:
29
api/handlers/explorer.go
Normal file
29
api/handlers/explorer.go
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user