Peter Kurfer
82a651cd5d
- replaced previous net/http based muxer and all other components with fiber - replaced polling with SSE to handle file changes - auto-update custom stylesheets - natively support mermaid diagrams - handle custom element attributes for lists properly - reload on config changes - replace JS templating with actual JS code and an API
25 lines
538 B
Go
25 lines
538 B
Go
package api
|
|
|
|
import (
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
"github.com/baez90/goveal/config"
|
|
)
|
|
|
|
type ConfigAPI struct {
|
|
cfg *config.Components
|
|
}
|
|
|
|
func RegisterConfigAPI(app *fiber.App, cfg *config.Components) {
|
|
cfgApi := &ConfigAPI{cfg: cfg}
|
|
app.Get("/api/v1/config/reveal", cfgApi.RevealConfig)
|
|
app.Get("/api/v1/config/mermaid", cfgApi.MermaidConfig)
|
|
}
|
|
|
|
func (a *ConfigAPI) RevealConfig(ctx *fiber.Ctx) error {
|
|
return ctx.JSON(a.cfg.Reveal)
|
|
}
|
|
|
|
func (a *ConfigAPI) MermaidConfig(ctx *fiber.Ctx) error {
|
|
return ctx.JSON(a.cfg.Mermaid)
|
|
}
|