示例#1
0
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)
}
示例#2
0
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)
}
示例#3
0
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)
}
示例#4
0
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)
}
示例#5
0
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)
}