Adding new errors and centralising handling
This commit is contained in:
@@ -85,7 +85,7 @@ func (s *Server) getNotes(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *Server) createNote(w http.ResponseWriter, r *http.Request) {
|
||||
note := struct {
|
||||
Content string `json:"content"`
|
||||
Title string `json:"title"`
|
||||
Title string `json:"title"`
|
||||
}{}
|
||||
if err := json.NewDecoder(r.Body).Decode(¬e); err != nil {
|
||||
http.Error(w, "invalid request body", http.StatusBadRequest)
|
||||
@@ -123,7 +123,7 @@ func (s *Server) updateNoteByID(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
note := struct {
|
||||
Content string `json:"content"`
|
||||
Title string `json:"title"`
|
||||
Title string `json:"title"`
|
||||
}{}
|
||||
if err := json.NewDecoder(r.Body).Decode(¬e); err != nil {
|
||||
http.Error(w, "invalid request body", http.StatusBadRequest)
|
||||
|
||||
Reference in New Issue
Block a user