feat(logger): implement a logger middleware
This commit is contained in:
parent
4ff490806c
commit
2cdbc4e782
4 changed files with 117 additions and 1 deletions
|
@ -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)
|
||||
|
|
|
@ -11,6 +11,7 @@ func addRoutes(
|
|||
db *database.DB,
|
||||
) {
|
||||
mux.Handle("GET /healthz", handleHealthz())
|
||||
|
||||
mux.Handle("GET /", handleGet(db))
|
||||
mux.Handle("POST /", handlePost(db))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue