Returning pagination metadata.
All checks were successful
Deploy Greenlight API / deploy (push) Successful in 2m48s
All checks were successful
Deploy Greenlight API / deploy (push) Successful in 2m48s
This commit is contained in:
@@ -237,14 +237,14 @@ func (app *application) listMoviesHandler(w http.ResponseWriter, r *http.Request
|
||||
}
|
||||
|
||||
// Call the GetAll() method to retrieve the movies, passing in the various filter parameters.
|
||||
movies, err := app.models.Movies.GetAll(input.Title, input.Genres, input.Filters)
|
||||
movies, metadata, err := app.models.Movies.GetAll(input.Title, input.Genres, input.Filters)
|
||||
if err != nil {
|
||||
app.serverErrorResponse(w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
// Send a JSON response containing the movie data
|
||||
err = app.writeJSON(w, http.StatusOK, envelope{"movies": movies}, nil)
|
||||
err = app.writeJSON(w, http.StatusOK, envelope{"movies": movies, "metadata": metadata}, nil)
|
||||
if err != nil {
|
||||
app.serverErrorResponse(w, r, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user