diff options
| author | Paul Buetow <paul@buetow.org> | 2024-07-14 23:55:53 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2024-07-14 23:55:53 +0300 |
| commit | 95b055a9f40787d15c42927041c9e65c49b05ea5 (patch) | |
| tree | 62a3361cf520077c88a4c672810e9f31c7549954 /cmd | |
| parent | 50b06ab176a24d7ee842e3e07d7462ef465b6762 (diff) | |
make it all context.Context aware
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/gosd/main.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/cmd/gosd/main.go b/cmd/gosd/main.go index e6080e0..6d11756 100644 --- a/cmd/gosd/main.go +++ b/cmd/gosd/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "flag" "fmt" "log" @@ -24,13 +25,16 @@ func main() { hand = handler.New(conf) ) + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + serv.Handle("health", func(w http.ResponseWriter, r *http.Request) error { fmt.Fprint(w, serv.Status.String()) return nil }) serv.Handle("submit", func(w http.ResponseWriter, r *http.Request) error { - return hand.Submit(w, r) + return hand.Submit(ctx, w, r) }) serv.Handle("list", func(w http.ResponseWriter, r *http.Request) error { @@ -42,7 +46,7 @@ func main() { }) serv.Handle("merge", func(w http.ResponseWriter, r *http.Request) error { - return hand.Merge(w, r) + return hand.Merge(ctx, w, r) }) log.Println("Server is starting on", conf.ListenAddr) |
