github.com/awesome-flow/flow@v0.0.3-0.20190918184116-508d75d68a2c/web/app/agent/config.go (about) 1 package agent 2 3 import ( 4 "encoding/json" 5 "net/http" 6 7 core "github.com/awesome-flow/flow/pkg/corev1alpha1" 8 ) 9 10 type ConfigPage struct { 11 Title string 12 Config string 13 } 14 15 func init() { 16 RegisterWebAgent( 17 func(ctx *core.Context) (WebAgent, error) { 18 return NewDummyWebAgent( 19 "/config", 20 func(rw http.ResponseWriter, req *http.Request) { 21 cfgdata := ctx.Config().Explain() 22 js, err := json.Marshal(cfgdata) 23 if err != nil { 24 rw.WriteHeader(http.StatusInternalServerError) 25 rw.Write([]byte(err.Error())) 26 return 27 } 28 respondWith(rw, RespHtml, "config", &ConfigPage{ 29 Title: "Flow active config", 30 Config: string(js), 31 }) 32 }, 33 ), nil 34 }, 35 ) 36 }