From b95244cd653294e1e2ac2d431bf3b3fd527e4307 Mon Sep 17 00:00:00 2001 From: Cyril Duez Date: Fri, 27 May 2016 10:19:33 +0200 Subject: [PATCH] Make the router public. --- agent/agent.go | 2 +- internal/webserver/webserver.go | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/agent/agent.go b/agent/agent.go index 43bec8837..e0cc82e72 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -342,7 +342,7 @@ func (a *Agent) Run(shutdown chan struct{}) error { defer p.Stop() case telegraf.WebhookInput: acc := createAccumulatorForInput(a, input, metricC) - if err := p.Register(webserver.Router(), acc); err != nil { + if err := p.Register(webserver.Router, acc); err != nil { log.Printf("Webhook for input %s failed to start, exiting\n%s\n", input.Name, err.Error()) return err diff --git a/internal/webserver/webserver.go b/internal/webserver/webserver.go index 4e3266094..5f68e98e0 100644 --- a/internal/webserver/webserver.go +++ b/internal/webserver/webserver.go @@ -10,19 +10,15 @@ import ( type Webserver struct { ServiceAddress string - router *mux.Router + Router *mux.Router } func NewWebserver(serviceAddress string) *Webserver { return &Webserver{Router: mux.NewRouter(), ServiceAddress: serviceAddress} } -func (wb *Webserver) Router() *mux.Router { - return wb.router -} - func (wb *Webserver) Listen() { - err := http.ListenAndServe(fmt.Sprintf("%s", wb.ServiceAddress), wb.router) + err := http.ListenAndServe(fmt.Sprintf("%s", wb.ServiceAddress), wb.Router) if err != nil { log.Printf("Error starting server: %v", err) }