From d53408d7b404dd875d32eb504f76a96156066b23 Mon Sep 17 00:00:00 2001 From: Hank Donnay Date: Mon, 8 Jan 2024 12:47:32 -0600 Subject: [PATCH] httptransport: add unauthenticated "/robots.txt" endpoint Signed-off-by: Hank Donnay --- httptransport/server.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/httptransport/server.go b/httptransport/server.go index 9bc94b055e..30bd95cffa 100644 --- a/httptransport/server.go +++ b/httptransport/server.go @@ -101,7 +101,6 @@ func New(ctx context.Context, conf *config.Config, indexer indexer.Service, matc if conf.Mode == config.ComboMode && notifier == nil { zlog.Debug(ctx).Msg("skipping unconfigured notifier") } - var ret http.Handler = mux // Add endpoint authentication if configured to add auth. Must happen after // mux was configured for given mode. if conf.Auth.Any() { @@ -112,9 +111,13 @@ func New(ctx context.Context, conf *config.Config, indexer indexer.Service, matc Msg("received error configuring auth middleware") return nil, err } - ret = h + final := http.NewServeMux() + final.Handle("/robots.txt", robotsHandler) + final.Handle("/", h) + return final, nil } - return ret, nil + mux.Handle("/robots.txt", robotsHandler) + return mux, nil } // IntraserviceIssuer is the issuer that will be used if Clair is configured to