Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dumindu/4bbbb98c9db14963a2cfd786b3323a93 to your computer and use it in GitHub Desktop.
Save dumindu/4bbbb98c9db14963a2cfd786b3323a93 to your computer and use it in GitHub Desktop.
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