Creating Movie struct inside internal/data/movies.go to be used in cmd/api/movies.go. Updating the showMovieHandler with the Movie struct.

This commit is contained in:
Maxime Delporte
2025-10-19 11:03:04 +02:00
parent 1b886109be
commit 9a0cb4db10
2 changed files with 40 additions and 2 deletions

18
internal/data/movies.go Normal file
View File

@@ -0,0 +1,18 @@
package data
import "time"
// Movie
/*
Annotate the Movie struct with struct tags to control how the keys
appear in the JSON-encoded output.
*/
type Movie struct {
ID int64 `json:"id"`
CreatedAt time.Time `json:"-"`
Title string `json:"title"`
Year int32 `json:"year,omitempty"`
Runtime int32 `json:"runtime,omitempty,string"`
Genres []string `json:"genres,omitempty"`
Version int32 `json:"version"`
}