Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct use of config write-tracing on the httpd handler #3021

Merged
merged 1 commit into from
Jun 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions services/httpd/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,11 @@ pprof-enabled = true
t.Fatalf("unexpected pprof enabled: %v", c.PprofEnabled)
}
}

func TestConfig_WriteTracing(t *testing.T) {
c := httpd.Config{WriteTracing: true}
s := httpd.NewService(c)
if !s.Handler.WriteTrace {
t.Fatalf("write tracing was not set")
}
}
3 changes: 2 additions & 1 deletion services/httpd/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,13 @@ type Handler struct {
}

// NewHandler returns a new instance of handler with routes.
func NewHandler(requireAuthentication, loggingEnabled bool) *Handler {
func NewHandler(requireAuthentication, loggingEnabled, writeTrace bool) *Handler {
h := &Handler{
mux: pat.New(),
requireAuthentication: requireAuthentication,
Logger: log.New(os.Stderr, "[http] ", log.LstdFlags),
loggingEnabled: loggingEnabled,
WriteTrace: writeTrace,
}

h.SetRoutes([]route{
Expand Down
2 changes: 1 addition & 1 deletion services/httpd/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ type Handler struct {
// NewHandler returns a new instance of Handler.
func NewHandler(requireAuthentication bool) *Handler {
h := &Handler{
Handler: httpd.NewHandler(requireAuthentication, true),
Handler: httpd.NewHandler(requireAuthentication, true, false),
}
h.Handler.MetaStore = &h.MetaStore
h.Handler.QueryExecutor = &h.QueryExecutor
Expand Down
1 change: 1 addition & 0 deletions services/httpd/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func NewService(c Config) *Service {
Handler: NewHandler(
c.AuthEnabled,
c.LogEnabled,
c.WriteTracing,
),
Logger: log.New(os.Stderr, "[httpd] ", log.LstdFlags),
}
Expand Down