diff options
Diffstat (limited to 'src/k8splugin/api')
-rw-r--r-- | src/k8splugin/api/api.go | 1 | ||||
-rw-r--r-- | src/k8splugin/api/instancehandler.go | 10 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/k8splugin/api/api.go b/src/k8splugin/api/api.go index 33eaefca..94fb9b34 100644 --- a/src/k8splugin/api/api.go +++ b/src/k8splugin/api/api.go @@ -50,6 +50,7 @@ func NewRouter(defClient rb.DefinitionManager, Queries("rb-name", "{rb-name}", "rb-version", "{rb-version}", "profile-name", "{profile-name}").Methods("GET") + //Want to get full Data -> add query param: /install/{instID}?full=true instRouter.HandleFunc("/instance/{instID}", instHandler.getHandler).Methods("GET") instRouter.HandleFunc("/instance/{instID}/status", instHandler.statusHandler).Methods("GET") instRouter.HandleFunc("/instance/{instID}/query", instHandler.queryHandler).Methods("GET") diff --git a/src/k8splugin/api/instancehandler.go b/src/k8splugin/api/instancehandler.go index 3baa8065..3fc514cd 100644 --- a/src/k8splugin/api/instancehandler.go +++ b/src/k8splugin/api/instancehandler.go @@ -122,8 +122,15 @@ func (i instanceHandler) createHandler(w http.ResponseWriter, r *http.Request) { func (i instanceHandler) getHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) id := vars["instID"] + var resp interface{} + var err error + + if r.URL.Query().Get("full") == "true" { + resp, err = i.client.GetFull(id) + } else { + resp, err = i.client.Get(id) + } - resp, err := i.client.Get(id) if err != nil { log.Error("Error getting Instance", log.Fields{ "error": err, @@ -132,7 +139,6 @@ func (i instanceHandler) getHandler(w http.ResponseWriter, r *http.Request) { http.Error(w, err.Error(), http.StatusInternalServerError) return } - w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) err = json.NewEncoder(w).Encode(resp) |