@@ -72,12 +72,6 @@ func main() {
7272 }
7373 })
7474
75- if c .healthCheckPath != "" {
76- http .HandleFunc (c .healthCheckPath , func (w http.ResponseWriter , r * http.Request ) {
77- w .WriteHeader (http .StatusOK )
78- })
79- }
80-
8175 // Listen & Serve
8276 log .Printf ("[service] listening on port %s" , c .port )
8377 if (len (c .sslCert ) > 0 ) && (len (c .sslKey ) > 0 ) {
@@ -274,9 +268,19 @@ func awss3(w http.ResponseWriter, r *http.Request) {
274268 path := r .URL .Path
275269 rangeHeader := r .Header .Get ("Range" )
276270
271+ // Strip the prefix, if it's present.
277272 if len (c .stripPath ) > 0 {
278- path = strings .Replace (path , c .stripPath , "" , 1 )
273+ path = strings .TrimPrefix (path , c .stripPath )
279274 }
275+
276+ // If there is a health check path defined, and if this path matches it,
277+ // then return 200 OK and return.
278+ // Note: we want to apply the health check *after* the prefix is stripped.
279+ if len (c .healthCheckPath ) > 0 && path == c .healthCheckPath {
280+ w .WriteHeader (http .StatusOK )
281+ return
282+ }
283+
280284 idx := strings .Index (path , "symlink.json" )
281285 if idx > - 1 {
282286 result , err := s3get (c .s3Bucket , c .s3KeyPrefix + path [:idx + 12 ], rangeHeader )
0 commit comments