Skip to content

Commit c3fd240

Browse files
committed
Remove debug endpoint from gcsweb
1 parent a160715 commit c3fd240

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

Diff for: gcsweb/cmd/gcsweb/gcsweb.go

+12-10
Original file line numberDiff line numberDiff line change
@@ -192,17 +192,19 @@ func main() {
192192

193193
logrus.Info("Starting GCSWeb")
194194

195+
mux := http.NewServeMux()
196+
195197
// Canonicalize allowed buckets.
196198
for i := range o.allowedBuckets {
197199
bucket := joinPath(gcsPath, o.allowedBuckets[i])
198200
logrus.WithField("bucket", bucket).Info("allowing bucket")
199-
http.HandleFunc(bucket+"/", s.gcsRequest)
200-
http.HandleFunc(bucket, func(w http.ResponseWriter, r *http.Request) {
201+
mux.HandleFunc(bucket+"/", s.gcsRequest)
202+
mux.HandleFunc(bucket, func(w http.ResponseWriter, r *http.Request) {
201203
http.Redirect(w, r, bucket+"/", http.StatusPermanentRedirect)
202204
})
203205
}
204206
// Handle unknown buckets.
205-
http.HandleFunc("/gcs/", unknownBucketRequest)
207+
mux.HandleFunc("/gcs/", unknownBucketRequest)
206208

207209
// Serve icons and styles.
208210
longCacheServer := func(h http.Handler) http.HandlerFunc {
@@ -217,25 +219,25 @@ func main() {
217219
}
218220

219221
if o.flIcons != "" { // If user specifies custom icons path then read it at runtime
220-
http.Handle("/icons/", longCacheServer(http.StripPrefix("/icons/", http.FileServer(http.Dir(o.flIcons)))))
222+
mux.Handle("/icons/", longCacheServer(http.StripPrefix("/icons/", http.FileServer(http.Dir(o.flIcons)))))
221223
} else {
222-
http.Handle("/icons/", longCacheServer(http.FileServer(http.FS(embededStatic))))
224+
mux.Handle("/icons/", longCacheServer(http.FileServer(http.FS(embededStatic))))
223225
}
224226
if o.flStyles != "" { // If user specifies custom styles path then read it at runtime
225-
http.Handle("/styles/", longCacheServer(http.StripPrefix("/styles/", http.FileServer(http.Dir(o.flStyles)))))
227+
mux.Handle("/styles/", longCacheServer(http.StripPrefix("/styles/", http.FileServer(http.Dir(o.flStyles)))))
226228
} else {
227-
http.Handle("/styles/", longCacheServer(http.FileServer(http.FS(embededStatic))))
229+
mux.Handle("/styles/", longCacheServer(http.FileServer(http.FS(embededStatic))))
228230
}
229231

230232
// Serve HTTP.
231-
http.HandleFunc("/robots.txt", robotsRequest)
232-
http.HandleFunc("/", otherRequest)
233+
mux.HandleFunc("/robots.txt", robotsRequest)
234+
mux.HandleFunc("/", otherRequest)
233235

234236
health := pjutil.NewHealthOnPort(o.instrumentationOptions.HealthPort)
235237
health.ServeReady()
236238

237239
logrus.Infof("serving on port %d", o.flPort)
238-
if err := http.ListenAndServe(fmt.Sprintf(":%d", o.flPort), nil); err != nil {
240+
if err := http.ListenAndServe(fmt.Sprintf(":%d", o.flPort), mux); err != nil {
239241
logrus.WithError(err).Fatal("couldn't start the http server")
240242
}
241243
}

0 commit comments

Comments
 (0)