package handler import ( "net/http" "projectreshoot/internal/config" "projectreshoot/internal/view/page" "strconv" "git.haelnorr.com/h/golib/hlog" "git.haelnorr.com/h/golib/tmdb" ) func Movie( config *config.Config, logger *hlog.Logger, ) http.Handler { return http.HandlerFunc( func(w http.ResponseWriter, r *http.Request) { id := r.PathValue("movie_id") movie_id, err := strconv.ParseInt(id, 10, 32) if err != nil { ErrorPage(http.StatusNotFound, w, r) logger.Error().Err(err).Str("movie_id", id). Msg("Error occured getting the movie") return } movie, err := tmdb.GetMovie(int32(movie_id), config.TMDBToken) if err != nil { ErrorPage(http.StatusInternalServerError, w, r) logger.Error().Err(err).Int32("movie_id", int32(movie_id)). Msg("Error occured getting the movie") return } credits, err := tmdb.GetCredits(int32(movie_id), config.TMDBToken) if err != nil { ErrorPage(http.StatusInternalServerError, w, r) logger.Error().Err(err).Int32("movie_id", int32(movie_id)). Msg("Error occured getting the movie credits") return } page.Movie(movie, credits, &config.TMDBConfig.Image).Render(r.Context(), w) }, ) }