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) }