From 9aa942c99d01829a05b07d7cb087849ea00887fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Cluseau?= Date: Wed, 1 Jul 2026 11:05:26 +0200 Subject: [PATCH] add GET /config --- cmd/dkl-local-server/ws-configs.go | 14 ++++++++++++++ cmd/dkl-local-server/ws.go | 3 +++ 2 files changed, 17 insertions(+) diff --git a/cmd/dkl-local-server/ws-configs.go b/cmd/dkl-local-server/ws-configs.go index c58243c..872ed79 100644 --- a/cmd/dkl-local-server/ws-configs.go +++ b/cmd/dkl-local-server/ws-configs.go @@ -13,6 +13,20 @@ import ( "novit.tech/direktil/pkg/localconfig" ) +func wsFetchConfig(req *restful.Request, resp *restful.Response) { + cfg, err := readConfig() + if err != nil { + if os.IsNotExist(err) { + wsNotFound(resp) + } else { + wsError(resp, httperr.Internal(err)) + } + return + } + + resp.WriteEntity(cfg) +} + func wsUploadConfig(req *restful.Request, resp *restful.Response) { cfg := &localconfig.Config{} if err := req.ReadEntity(cfg); err != nil { diff --git a/cmd/dkl-local-server/ws.go b/cmd/dkl-local-server/ws.go index 62540a3..6d3a911 100644 --- a/cmd/dkl-local-server/ws.go +++ b/cmd/dkl-local-server/ws.go @@ -73,6 +73,9 @@ func registerWS(rest *restful.Container) { Doc("Sign a download set")) // - configs API + ws.Route(ws.GET("/config").To(wsFetchConfig). + Produces(mime.JSON, mime.YAML). + Doc("Fetch the current configuration")) ws.Route(ws.POST("/configs").To(wsUploadConfig). Consumes(mime.YAML, mime.JSON).Param(ws.BodyParameter("config", "The new full configuration")). Produces(mime.JSON).Writes(true).