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) }
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) }
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) }
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) }
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) }