diff --git a/.gitignore b/.gitignore index 179a43c..4616b4a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /cmd/aggregadantur/aggregadantur /*.json config.yml +/aggregadantur diff --git a/README.md b/README.md index 084a086..201fc1d 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,8 @@ func main() { })) // create a router, and add it a session store, here it is a cookie store, it is for saving session with token. - rtr := aggregadantur.NewRouter(sessions.NewCookieStore([]byte(myConfig.SessionKey))) + sess := sessions.NewCookieStore([]byte(myConfig.SessionKey)) + rtr := aggregadantur.NewRouter(sess) // add you aggregate route err = rtr.AddMuxRoute(aggrRoute) if err != nil { diff --git a/cmd/aggregadantur/main.go b/cmd/aggregadantur/main.go index 5fb0e10..487aad6 100644 --- a/cmd/aggregadantur/main.go +++ b/cmd/aggregadantur/main.go @@ -27,7 +27,8 @@ func main() { return } - router := aggregadantur.NewRouter(sessions.NewCookieStore([]byte(c.Server.SessionKey))) + sess := sessions.NewCookieStore([]byte(c.Server.SessionKey)) + router := aggregadantur.NewRouter(sess) err = router.AddMuxRoutes(c.Routes...) if err != nil { log.Fatal("Error loading routes: ", err.Error()) diff --git a/routing.go b/routing.go index de010ef..adcdecf 100644 --- a/routing.go +++ b/routing.go @@ -15,17 +15,23 @@ import ( ) type Router struct { - rtr *mux.Router - store sessions.Store + rtr *mux.Router + store sessions.Store + tracer bool } func NewRouter(store sessions.Store) *Router { return &Router{ - rtr: mux.NewRouter(), - store: store, + rtr: mux.NewRouter(), + store: store, + tracer: true, } } +func (r Router) DisableTracer() { + r.tracer = false +} + func (r Router) AddMuxRoute(route *models.AggregateRoute) error { httpClient := makeHttpClient(route.InsecureSkipVerify) var handler http.Handler @@ -41,7 +47,10 @@ func (r Router) AddMuxRoute(route *models.AggregateRoute) error { handler = NewAggregateHandler(handler, route, httpClient) handler = NewAuthHandler(handler, route, httpClient, r.store) - handler, err = trace.New(handler, log.StandardLogger().Out) + if r.tracer { + handler, err = trace.New(handler, log.StandardLogger().Out) + } + if err != nil { return err }