ch3.3
This commit is contained in:
@@ -3,6 +3,9 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"gitea.local.lab/Lbenedar/greenlight/internal/data"
|
||||
)
|
||||
|
||||
func (app *application) createMovieHandler(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -15,5 +18,19 @@ func (app *application) showMovieHandler(w http.ResponseWriter, r *http.Request)
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
fmt.Fprintf(w, "show the details of movie %d\n", id)
|
||||
|
||||
movie := data.Movie{
|
||||
ID: id,
|
||||
CreatedAt: time.Now(),
|
||||
Title: "Casablanca",
|
||||
Runtime: 102,
|
||||
Genres: []string{"drama", "romance", "war"},
|
||||
Version: 1,
|
||||
}
|
||||
|
||||
err = app.writeJSON(w, http.StatusOK, movie, nil)
|
||||
if err != nil {
|
||||
app.logger.Print(err)
|
||||
http.Error(w, "The server encountered a problem and could not process your request", http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user