Last active
October 5, 2019 08:59
-
-
Save dumindu/4bbbb98c9db14963a2cfd786b3323a93 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (app *App) HandleCreateBook(w http.ResponseWriter, r *http.Request) { | |
// after create form from decoding request Body | |
if err := app.validator.Struct(form); err != nil { | |
app.logger.Warn().Err(err).Msg("") | |
w.WriteHeader(http.StatusUnprocessableEntity) | |
fmt.Fprintf(w, `{"error": "%v"}`, err.Error()) | |
return | |
} | |
// ... | |
} | |
func (app *App) HandleUpdateBook(w http.ResponseWriter, r *http.Request) { | |
// after create form from decoding request Body | |
if err := app.validator.Struct(form); err != nil { | |
app.logger.Warn().Err(err).Msg("") | |
w.WriteHeader(http.StatusUnprocessableEntity) | |
fmt.Fprintf(w, `{"error": "%v"}`, err.Error()) | |
return | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment