2023-01-31 19:44:03 +01:00
|
|
|
package controller
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/go-openapi/runtime/middleware"
|
|
|
|
"github.com/openziti/zrok/build"
|
2023-03-13 19:19:38 +01:00
|
|
|
"github.com/openziti/zrok/controller/config"
|
2023-01-31 19:44:03 +01:00
|
|
|
"github.com/openziti/zrok/rest_model_zrok"
|
|
|
|
"github.com/openziti/zrok/rest_server_zrok/operations/metadata"
|
|
|
|
)
|
|
|
|
|
|
|
|
type configurationHandler struct {
|
2023-03-13 19:19:38 +01:00
|
|
|
cfg *config.Config
|
2023-01-31 19:44:03 +01:00
|
|
|
}
|
|
|
|
|
2023-03-13 19:19:38 +01:00
|
|
|
func newConfigurationHandler(cfg *config.Config) *configurationHandler {
|
2023-01-31 19:44:03 +01:00
|
|
|
return &configurationHandler{
|
|
|
|
cfg: cfg,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ch *configurationHandler) Handle(_ metadata.ConfigurationParams) middleware.Responder {
|
|
|
|
tou := ""
|
|
|
|
if cfg.Admin != nil {
|
|
|
|
tou = cfg.Admin.TouLink
|
|
|
|
}
|
|
|
|
data := &rest_model_zrok.Configuration{
|
|
|
|
Version: build.String(),
|
|
|
|
TouLink: tou,
|
|
|
|
}
|
|
|
|
return metadata.NewConfigurationOK().WithPayload(data)
|
|
|
|
}
|