Skip to content

Commit

Permalink
cmd: Improves usage of metrics middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
arekkas authored and arekkas committed May 29, 2018
1 parent 647c5a9 commit 301f386
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestExecute(t *testing.T) {
expectErr bool
}{
{
args: []string{"serve"},
args: []string{"--disable-telemetry", "serve"},
wait: func(t *testing.T) bool {
t.Logf("Trying to connect to port %d...", port)
_, err := http.DefaultClient.Get(fmt.Sprintf("http://127.0.0.1:%d/", port))
Expand Down
7 changes: 4 additions & 3 deletions cmd/server/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"net/http"
"strings"

"github.com/gorilla/context"
"github.com/julienschmidt/httprouter"
"github.com/meatballhat/negroni-logrus"
"github.com/ory/fosite"
Expand Down Expand Up @@ -106,7 +105,6 @@ func RunServe(

n := negroni.New()
n.Use(negronilogrus.NewMiddlewareFromLogger(logger, "keto"))
n.UseHandler(router)
corsHandler := cors.New(corsx.ParseOptions()).Handler(n)

if ok, _ := cmd.Flags().GetBool("disable-telemetry"); !ok {
Expand All @@ -122,16 +120,19 @@ func RunServe(
"/warden/oauth2/clients/authorize",
},
logger,
"ory-keto",
)
go m.RegisterSegment(buildVersion, buildHash, buildTime)
go m.CommitMemoryStatistics()
n.Use(m)
}

n.UseHandler(router)

address := fmt.Sprintf("%s:%s", viper.GetString("HOST"), viper.GetString("PORT"))
var srv = graceful.WithDefaults(&http.Server{
Addr: address,
Handler: context.ClearHandler(corsHandler),
Handler: corsHandler,
})

if err := graceful.Graceful(func() error {
Expand Down

0 comments on commit 301f386

Please sign in to comment.