Make the router public.
This commit is contained in:
parent
580dc733ee
commit
b95244cd65
|
@ -342,7 +342,7 @@ func (a *Agent) Run(shutdown chan struct{}) error {
|
||||||
defer p.Stop()
|
defer p.Stop()
|
||||||
case telegraf.WebhookInput:
|
case telegraf.WebhookInput:
|
||||||
acc := createAccumulatorForInput(a, input, metricC)
|
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",
|
log.Printf("Webhook for input %s failed to start, exiting\n%s\n",
|
||||||
input.Name, err.Error())
|
input.Name, err.Error())
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -10,19 +10,15 @@ import (
|
||||||
|
|
||||||
type Webserver struct {
|
type Webserver struct {
|
||||||
ServiceAddress string
|
ServiceAddress string
|
||||||
router *mux.Router
|
Router *mux.Router
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWebserver(serviceAddress string) *Webserver {
|
func NewWebserver(serviceAddress string) *Webserver {
|
||||||
return &Webserver{Router: mux.NewRouter(), ServiceAddress: serviceAddress}
|
return &Webserver{Router: mux.NewRouter(), ServiceAddress: serviceAddress}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wb *Webserver) Router() *mux.Router {
|
|
||||||
return wb.router
|
|
||||||
}
|
|
||||||
|
|
||||||
func (wb *Webserver) Listen() {
|
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 {
|
if err != nil {
|
||||||
log.Printf("Error starting server: %v", err)
|
log.Printf("Error starting server: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue