示例#1
0
func NewDeskHandler(w http.ResponseWriter, r *http.Request) {
	var desk data.Desk

	err := data.InsertFromJson(r.Body, &desk)
	if err != nil {
		http.Error(w, `{"error": "error creating desk: `+err.Error()+`"}`, http.StatusBadRequest)
		return
	}

	w.WriteHeader(http.StatusCreated)
	respond(w, "desk", desk)
}
示例#2
0
func NewPlaceHandler(w http.ResponseWriter, r *http.Request) {
	var place data.Place

	err := data.InsertFromJson(r.Body, &place)
	if err != nil {
		http.Error(w, `{"error": "error creating place: `+err.Error()+`"}`, http.StatusBadRequest)
		return
	}

	w.WriteHeader(http.StatusCreated)
	respond(w, "place", place)
}
示例#3
0
func NewUserHandler(w http.ResponseWriter, r *http.Request) {
	var u data.User

	err := data.InsertFromJson(r.Body, &u)
	if err != nil {
		http.Error(w, `{"error": "error creating user: `+err.Error()+`"}`, http.StatusBadRequest)
		return
	}

	w.WriteHeader(http.StatusCreated)
	respond(w, "user", u)
}
示例#4
0
func NewRoomHandler(w http.ResponseWriter, r *http.Request) {
	var room data.Room

	err := data.InsertFromJson(r.Body, &room)
	if err != nil {
		http.Error(w, `{"error": "error creating room: `+err.Error()+`"}`, http.StatusBadRequest)
		return
	}

	w.WriteHeader(http.StatusCreated)
	respond(w, "room", room)
}
示例#5
0
func NewSectionHandler(w http.ResponseWriter, r *http.Request) {
	var m data.Section

	err := data.InsertFromJson(r.Body, &m)
	if err != nil {
		http.Error(w, `{"error": "error creating section: `+err.Error()+`"}`, http.StatusBadRequest)
		return
	}

	w.WriteHeader(http.StatusCreated)
	respond(w, "section", m)
}