package router import ( "net/http" "github.com/ewhal/nyaa/service/torrent" "github.com/ewhal/nyaa/util/log" "github.com/gorilla/mux" ) func ViewHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) id := vars["id"] torrent, err := torrentService.GetTorrentById(id) if err != nil { NotFoundHandler(w, r) return } b := torrent.ToJson() htv := ViewTemplateVariables{b, NewSearchForm(), Navigation{}, GetUser(r), r.URL, mux.CurrentRoute(r)} err = viewTemplate.ExecuteTemplate(w, "index.html", htv) if err != nil { log.Errorf("ViewHandler(): %s", err) } }