|
|
|
|
@ -242,6 +242,15 @@ func (app *application) deleteMovieHandler(w http.ResponseWriter, r *http.Reques
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (app *application) listMoviesHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
movies, err := app.models.Movies.List(r.Context())
|
|
|
|
|
if err != nil {
|
|
|
|
|
app.serverErrorResponse(w, r, err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
app.writeJSON(w, 200, envelope{"movies": movies}, nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (app *application) healthCheckHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
// JSON has to be double quoted. FYI you would never really do this
|
|
|
|
|
// js := `{"status": "available", "environment": %q, "version": %q}`
|
|
|
|
|
|