From 8c62a63073236c68eb556f5304c8d5cea0aeede8 Mon Sep 17 00:00:00 2001 From: Adam Shannon Date: Wed, 17 Mar 2021 12:41:05 -0500 Subject: [PATCH] service: add route to render merged config --- pkg/service/server.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/service/server.go b/pkg/service/server.go index 9197db1e..c7b559da 100644 --- a/pkg/service/server.go +++ b/pkg/service/server.go @@ -3,7 +3,9 @@ package service import ( + "encoding/json" "fmt" + "net/http" "os" "path/filepath" @@ -19,6 +21,7 @@ import ( // RunServers - Boots up all the servers and awaits till they are stopped. func (env *Environment) RunServers(terminationListener chan error) func() { adminServer := bootAdminServer(terminationListener, env.Logger, env.Config.Servers.Admin) + env.serveConfig(adminServer) var shutdownFTPServer func() if env.Config.Servers.FTP != nil { @@ -96,3 +99,11 @@ func bootAdminServer(errs chan<- error, logger log.Logger, config HTTPConfig) *a return adminServer } + +func (env *Environment) serveConfig(svc *admin.Server) { + svc.AddHandler("/config", func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(http.StatusOK) + json.NewEncoder(w).Encode(env.Config) + }) +}