cosmium/api/handlers/explorer.go
2024-02-14 01:47:51 +02:00

30 lines
674 B
Go

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)
}
}