From 844b161e647ae35bffc5fee18726271ede98988f Mon Sep 17 00:00:00 2001 From: Zherphy <1123678689@qq.com> Date: Sat, 12 Oct 2024 14:43:53 +0800 Subject: [PATCH] ADD: add hello api add hello api --- server/server.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/server.go b/server/server.go index 746aa27..efbac77 100644 --- a/server/server.go +++ b/server/server.go @@ -96,6 +96,7 @@ func New(o Options) (http.Handler, error) { r := chi.NewRouter() r.Post("/{owner}/{repo}/objects/batch", s.handleBatch) + r.Get("/", s.helloCheck) return r, nil } @@ -234,6 +235,14 @@ func (s *server) handleBatch(w http.ResponseWriter, r *http.Request) { must(json.NewEncoder(w).Encode(resp)) } +func (s *server) helloCheck(w http.ResponseWriter, r *http.Request) { + _, err := w.Write([]byte("Hello, World!")) + if err != nil { + err = errors.New("health check failed") + return + } +} + // -- func must(err error) {