Skip to content

Instantly share code, notes, and snippets.

@d-smith
Created December 18, 2015 15:20
Show Gist options
  • Select an option

  • Save d-smith/e15be35dd2dcae38dfbe to your computer and use it in GitHub Desktop.

Select an option

Save d-smith/e15be35dd2dcae38dfbe to your computer and use it in GitHub Desktop.
Dumping config via expvar
"config dump": "\"\\\"\\\\\\\"\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"&{Name:demo-listener RouteNames:[demo-route-1 demo-route-2]}\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"&{Name:hello1 Address:localhost Port:3000 PingURI:/hello HealthCheck: HealthCheckInterval:0 HealthCheckTimeout:0}\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"{Name:demo-backend-1 LoadBalancer:0x1880ca70}\\\\\\\\\\\\\\\"&{Name:demo-route-1 URIRoot:/hello Backends:[demo-backend-1] Plugins:[] MultiBackendAdapter: MsgProps:SOAPAction=foo}\\\\\\\"&{Name:hello2 Address:localhost Port:3100 PingURI:/hello HealthCheck: HealthCheckInterval:0 HealthCheckTimeout:0}\\\"{Name:demo-backend-2 LoadBalancer:0x1880cdc0}\"&{Name:demo-route-2 URIRoot:/hello Backends:[demo-backend-2] Plugins:[] MultiBackendAdapter: MsgProps:SOAPAction=bar}",
var serviceConfig = expvar.NewMap("service-config")
const serviceConfigDump = "scd"
func init() {
configDump := expvar.NewString("config dump")
configDump.Set("")
serviceConfig.Set(serviceConfigDump, configDump)
}
func addConfigToDump(configString string) {
configDump, ok := serviceConfig.Get(serviceConfigDump).(*expvar.String)
if ok {
configDumpVal := configDump.String()
configDumpVal += configString
configDump.Set(configDumpVal)
serviceConfig.Set(serviceConfigDump, configDump)
}
}
addConfigToDump(fmt.Sprintf("%+v", serverConfig))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment