package main import ( "fmt" "net/http" "time" "greenlight.ergz/internal/data" ) func (app *application) createMovieHandler(w http.ResponseWriter, r *http.Request) { var input struct { Title string `json:"title"` Year int32 `json:"year"` Runtime int32 `json:"runtime"` Genres []string `json:"genres"` } err := app.readJSON(w, r, &input) if err != nil { app.badRequestResponse(w, r, err) return } fmt.Fprintf(w, "%v+\n", input) } func (app *application) showMovieHandler(w http.ResponseWriter, r *http.Request) { id, err := app.readIDParam(r) if err != nil { app.notFoundResponse(w, r) return } movie := data.Movie{ ID: id, CreatedAt: time.Now(), Title: "Casablanca", Runtime: 102, Genres: []string{"drama", "romance", "war"}, Version: 1, } envelopedMovie := envelope{"movie": movie} err = app.writeJSON(w, http.StatusOK, envelopedMovie, nil) if err != nil { app.serverErrorResponse(w, r, err) } }