storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/cmd/healthcheck-router.go (about) 1 /* 2 * MinIO Cloud Storage, (C) 2018 MinIO, Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package cmd 18 19 import ( 20 "net/http" 21 22 "github.com/gorilla/mux" 23 ) 24 25 const ( 26 healthCheckPath = "/health" 27 healthCheckLivenessPath = "/live" 28 healthCheckReadinessPath = "/ready" 29 healthCheckClusterPath = "/cluster" 30 healthCheckClusterReadPath = "/cluster/read" 31 healthCheckPathPrefix = minioReservedBucketPath + healthCheckPath 32 ) 33 34 // registerHealthCheckRouter - add handler functions for liveness and readiness routes. 35 func registerHealthCheckRouter(router *mux.Router) { 36 37 // Healthcheck router 38 healthRouter := router.PathPrefix(healthCheckPathPrefix).Subrouter() 39 40 // Cluster check handler to verify cluster is active 41 healthRouter.Methods(http.MethodGet).Path(healthCheckClusterPath).HandlerFunc(HTTPTraceAll(ClusterCheckHandler)) 42 healthRouter.Methods(http.MethodGet).Path(healthCheckClusterReadPath).HandlerFunc(HTTPTraceAll(ClusterReadCheckHandler)) 43 44 // Liveness handler 45 healthRouter.Methods(http.MethodGet).Path(healthCheckLivenessPath).HandlerFunc(HTTPTraceAll(LivenessCheckHandler)) 46 healthRouter.Methods(http.MethodHead).Path(healthCheckLivenessPath).HandlerFunc(HTTPTraceAll(LivenessCheckHandler)) 47 48 // Readiness handler 49 healthRouter.Methods(http.MethodGet).Path(healthCheckReadinessPath).HandlerFunc(HTTPTraceAll(ReadinessCheckHandler)) 50 healthRouter.Methods(http.MethodHead).Path(healthCheckReadinessPath).HandlerFunc(HTTPTraceAll(ReadinessCheckHandler)) 51 }