This commit is contained in:
lbenedar
2026-03-17 12:06:27 +03:00
parent 71f15d1131
commit 4694f0aa2f

View File

@@ -1,6 +1,7 @@
package main package main
import ( import (
"encoding/json"
"fmt" "fmt"
"net/http" "net/http"
"time" "time"
@@ -9,7 +10,19 @@ import (
) )
func (app *application) createMovieHandler(w http.ResponseWriter, r *http.Request) { func (app *application) createMovieHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "create a new movie") var input struct {
Title string `json:"title"`
Year int32 `json:"year"`
Runtime int32 `json:"runtime"`
Genres []string `json:"genres"`
}
err := json.NewDecoder(r.Body).Decode(&input)
if err != nil {
app.errorResponse(w, r, http.StatusBadRequest, err.Error())
return
}
fmt.Fprintf(w, "%+v\n", input)
} }
func (app *application) showMovieHandler(w http.ResponseWriter, r *http.Request) { func (app *application) showMovieHandler(w http.ResponseWriter, r *http.Request) {