From 62161686c43bce28f2d1060afb65e80ba54d3b15 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..16b48a5 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("/hello", 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) {