func ListProfilesHandler(w http.ResponseWriter, r *http.Request) { var response ProfilesResponse profiles, err := GetProfiles() if err != nil { log.Println(err.Error()) http.Error(w, err.Error(), 500) } response.Profiles = profiles httputils.JSONWrite(w, response, 200) }
func ListSSHKeyHandler(w http.ResponseWriter, r *http.Request) { var response SSHKeysResponse sshkeys, err := GetSSHKeys() if err != nil { log.Println(err.Error()) http.Error(w, err.Error(), 500) } response.SSHKeys = sshkeys httputils.JSONWrite(w, response, 200) }
func ListCloudConfigHandler(w http.ResponseWriter, r *http.Request) { var response CloudConfigsResponse cloudconfigs, err := GetCloudConfigs() if err != nil { log.Println(err.Error()) http.Error(w, err.Error(), 500) } response.CloudConfigs = cloudconfigs httputils.JSONWrite(w, response, 200) }
func ListMachinesHandler(w http.ResponseWriter, r *http.Request) { var response Response machines, err := GetMachines() if err != nil { log.Println(err.Error()) http.Error(w, err.Error(), 500) } response.Machines = machines httputils.JSONWrite(w, response, 200) }
func GetProfileHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) p, err := GetProfileByName(vars["name"]) if err == ErrNotFound { http.NotFound(w, r) return } if err != nil { httputils.JSONError(w, err.Error(), 500) return } httputils.JSONWrite(w, p, 200) }