Skip to content

Commit

Permalink
service: add route to render merged config
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdecaf committed Mar 17, 2021
1 parent 7edf17c commit 8c62a63
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/service/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
package service

import (
"encoding/json"
"fmt"
"net/http"
"os"
"path/filepath"

Expand All @@ -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 {
Expand Down Expand Up @@ -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)
})
}

0 comments on commit 8c62a63

Please sign in to comment.