From 2cdbc4e782c7ad7f42b1ddd3b7be6a24dea580e7 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Tue, 1 Oct 2024 08:47:32 +0200 Subject: feat(logger): implement a logger middleware --- cmd/tfstated/main.go | 3 ++- cmd/tfstated/routes.go | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/tfstated/main.go b/cmd/tfstated/main.go index 61248bc..cf93976 100644 --- a/cmd/tfstated/main.go +++ b/cmd/tfstated/main.go @@ -14,6 +14,7 @@ import ( "time" "git.adyxax.org/adyxax/tfstated/pkg/database" + "git.adyxax.org/adyxax/tfstated/pkg/logger" ) type Config struct { @@ -49,7 +50,7 @@ func run( httpServer := &http.Server{ Addr: net.JoinHostPort(config.Host, config.Port), - Handler: mux, + Handler: logger.Middleware(mux), } go func() { log.Printf("listening on %s\n", httpServer.Addr) diff --git a/cmd/tfstated/routes.go b/cmd/tfstated/routes.go index 32ab111..853970a 100644 --- a/cmd/tfstated/routes.go +++ b/cmd/tfstated/routes.go @@ -11,6 +11,7 @@ func addRoutes( db *database.DB, ) { mux.Handle("GET /healthz", handleHealthz()) + mux.Handle("GET /", handleGet(db)) mux.Handle("POST /", handlePost(db)) } -- cgit v1.2.3