Esempio n. 1
0
func CreateProfileHandler(w http.ResponseWriter, r *http.Request) {
	var p Profile
	if err := httputils.UnmarshalJSONBody(r.Body, &p); err != nil {
		httputils.JSONError(w, err.Error(), 500)
	}
	if err := p.Save(); err != nil {
		httputils.JSONError(w, err.Error(), 500)
	}
	httputils.SetLocationHeader(w, "http://localhost:8080/profiles/"+p.Name)
	w.WriteHeader(http.StatusCreated)
}
Esempio n. 2
0
func CreateSSHKeyHandler(w http.ResponseWriter, r *http.Request) {
	var s SSHKey
	if err := httputils.UnmarshalJSONBody(r.Body, &s); err != nil {
		httputils.JSONError(w, err.Error(), 500)
	}
	if err := s.Save(); err != nil {
		httputils.JSONError(w, err.Error(), 500)
	}
	httputils.SetLocationHeader(w, "http://localhost:8080/sshkeys/"+s.Name)
	w.WriteHeader(http.StatusCreated)
}
Esempio n. 3
0
func CreateCloudConfigHandler(w http.ResponseWriter, r *http.Request) {
	var c CloudConfig
	if err := httputils.UnmarshalJSONBody(r.Body, &c); err != nil {
		httputils.JSONError(w, err.Error(), 500)
	}
	if err := c.Save(); err != nil {
		httputils.JSONError(w, err.Error(), 500)
	}
	httputils.SetLocationHeader(w, "http://localhost:8080/cloudconfigs/"+c.Name)
	w.WriteHeader(http.StatusCreated)
}
Esempio n. 4
0
func CreateMachineHandler(w http.ResponseWriter, r *http.Request) {
	var m Machine
	if err := httputils.UnmarshalJSONBody(r.Body, &m); err != nil {
		httputils.JSONError(w, err.Error(), 500)
	}
	if err := m.Save(); err != nil {
		httputils.JSONError(w, err.Error(), 500)
	}
	httputils.SetLocationHeader(w, "http://localhost:8080/machines/"+m.Name)
	w.WriteHeader(http.StatusCreated)
}