func Index entities Session render Render interactors GuideInteractor

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
func Index(s *entities.Session, r render.Render, i *interactors.GuideInteractor, req *http.Request) {
if !s.IsValid() && !strings.HasSuffix(req.Referer(), "/welcome") {
r.Redirect("/welcome", http.StatusFound)
return
}
now := time.Now()
timer := metrics.GetOrRegisterTimer("app.index", metrics.DefaultRegistry)
type collections map[string]Guides
pipeline := struct {
Collections collections
Component utils.ReactComponent
}{collections{}, utils.ReactComponent{"search", nil}}
for key, sorterList := range implementation.SupportedGuideSortedLists {
collection, _, err := i.FindAllPublishedGuides(entities.PagerAll, sorterList)
if err != nil {
r.HTML(http.StatusOK, "sys.error", err)
return
}
pipeline.Collections[string(key)] = collection
}
r.HTML(http.StatusOK, "marketplace.index", pipeline)
timer.UpdateSince(now)
}