Skip to content

Commit 58265a5

Browse files
committed
server: add a healthcheck route at /_internal/healthcheck
Closes #904.
1 parent 8edf84e commit 58265a5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

fakestorage/server.go

+7
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ func (s *Server) buildMuxer() {
215215
const apiPrefix = "/storage/v1"
216216
s.mux = mux.NewRouter()
217217

218+
// healthcheck
219+
s.mux.Path("/_internal/healthcheck").Methods(http.MethodGet).HandlerFunc(s.healthcheck)
220+
218221
routers := []*mux.Router{
219222
s.mux.PathPrefix(apiPrefix).Subrouter(),
220223
s.mux.MatcherFunc(s.publicHostMatcher).PathPrefix(apiPrefix).Subrouter(),
@@ -268,6 +271,10 @@ func (s *Server) buildMuxer() {
268271
s.mux.Host("{bucketName:.+}").Path("/{objectName:.+}").Methods(http.MethodPost, http.MethodPut).HandlerFunc(jsonToHTTPHandler(s.insertObject))
269272
}
270273

274+
func (s *Server) healthcheck(w http.ResponseWriter, r *http.Request) {
275+
w.WriteHeader(http.StatusOK)
276+
}
277+
271278
// publicHostMatcher matches incoming requests against the currently specified server publicHost.
272279
func (s *Server) publicHostMatcher(r *http.Request, rm *mux.RouteMatch) bool {
273280
if strings.Contains(s.publicHost, ":") || !strings.Contains(r.Host, ":") {

0 commit comments

Comments
 (0)