From 47c1da65a9145831b055dfae53bf93ccaf877e62 Mon Sep 17 00:00:00 2001 From: Michal Fudala Date: Mon, 15 Jul 2024 19:57:04 +0200 Subject: [PATCH] add handler for new discovery endpoint so that CLI tools like bq work (fix for #290) --- server/handler.go | 5 +++-- server/server.go | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/server/handler.go b/server/handler.go index d84d71ba5..7181482af 100644 --- a/server/handler.go +++ b/server/handler.go @@ -53,8 +53,9 @@ func encodeResponse(ctx context.Context, w http.ResponseWriter, response interfa } const ( - discoveryAPIEndpoint = "/discovery/v1/apis/bigquery/v2/rest" - uploadAPIEndpoint = "/upload/bigquery/v2/projects/{projectId}/jobs" + discoveryAPIEndpoint = "/discovery/v1/apis/bigquery/v2/rest" + newDiscoveryAPIEndpoint = "/$discovery/rest" + uploadAPIEndpoint = "/upload/bigquery/v2/projects/{projectId}/jobs" ) //go:embed resources/discovery.json diff --git a/server/server.go b/server/server.go index 5194902e0..14ffbcb4a 100644 --- a/server/server.go +++ b/server/server.go @@ -79,6 +79,7 @@ func New(storage Storage) (*Server, error) { r.Handle(fmt.Sprintf("/bigquery/v2%s", handler.Path), handler.Handler).Methods(handler.HTTPMethod) } r.Handle(discoveryAPIEndpoint, newDiscoveryHandler(server)).Methods("GET") + r.Handle(newDiscoveryAPIEndpoint, newDiscoveryHandler(server)).Methods("GET") r.Handle(uploadAPIEndpoint, &uploadHandler{}).Methods("POST") r.Handle(uploadAPIEndpoint, &uploadContentHandler{}).Methods("PUT") r.PathPrefix("/").Handler(&defaultHandler{})