From fe9f200606e4cdd2841fc3a6a8effa7aa20f4dba Mon Sep 17 00:00:00 2001 From: rapitable Date: Tue, 22 Aug 2017 08:46:45 +0200 Subject: [PATCH] Improve error message if an older CLI attempts to make a request (#291) Closes #290 --- controller/api.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/controller/api.go b/controller/api.go index a601a405..fa960cdb 100644 --- a/controller/api.go +++ b/controller/api.go @@ -95,8 +95,15 @@ func (api *API) HomeHandler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "{\"message\": \"Fission API\", \"version\": \"0.1.0\"}\n") } +func (api *API) ApiVersionMismatchHandler(w http.ResponseWriter, r *http.Request) { + err := fission.MakeError(fission.ErrorNotFound, "Fission server supports API v2 only - v1 is not supported. Please upgrade your Fission client / CLI") + api.respondWithError(w, err) +} + func (api *API) Serve(port int) { r := mux.NewRouter() + // Give a useful error message if an older CLI attempts to make a request + r.HandleFunc(`/v1/{rest:[a-zA-Z0-9=\-\/]+}`, api.ApiVersionMismatchHandler) r.HandleFunc("/", api.HomeHandler) r.HandleFunc("/v2/functions", api.FunctionApiList).Methods("GET")