Skip to content

Commit

Permalink
Merge pull request #846 from go-kivik/up
Browse files Browse the repository at this point in the history
Add _up endpoint
  • Loading branch information
flimzy authored Dec 13, 2023
2 parents 071785b + 4cb049e commit e57e528
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
10 changes: 9 additions & 1 deletion x/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (s *Server) routes(mux *chi.Mux) {
auth.Post("/_search_analyze", httpe.ToHandler(s.notImplemented()).ServeHTTP)
auth.Get("/_utils", httpe.ToHandler(s.notImplemented()).ServeHTTP)
auth.Get("/_utils/", httpe.ToHandler(s.notImplemented()).ServeHTTP)
mux.Get("/_up", httpe.ToHandler(s.notImplemented()).ServeHTTP)
mux.Get("/_up", httpe.ToHandler(s.up()).ServeHTTP)
auth.Get("/_uuids", httpe.ToHandler(s.notImplemented()).ServeHTTP)
mux.Get("/favicon.ico", httpe.ToHandler(s.notImplemented()).ServeHTTP)
auth.Get("/_reshard", httpe.ToHandler(s.notImplemented()).ServeHTTP)
Expand Down Expand Up @@ -290,3 +290,11 @@ func (s *Server) dbExists() httpe.HandlerWithError {
return nil
})
}

func (s *Server) up() httpe.HandlerWithError {
return httpe.HandlerWithErrorFunc(func(w http.ResponseWriter, r *http.Request) error {
return serveJSON(w, http.StatusOK, map[string]interface{}{
"status": "ok",
})
})
}
9 changes: 9 additions & 0 deletions x/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,15 @@ func TestServer(t *testing.T) {
"ok": true,
},
},
{
name: "_up",
method: http.MethodGet,
path: "/_up",
wantStatus: http.StatusOK,
wantJSON: map[string]interface{}{
"status": "ok",
},
},
}

for _, tt := range tests {
Expand Down

0 comments on commit e57e528

Please sign in to comment.