-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.go
31 lines (29 loc) · 679 Bytes
/
search.go
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
28
29
30
31
package main
import (
"log"
"net/http"
"time"
)
// Search returns the root path of `/` for in-browser search
func (a *App) Search(w http.ResponseWriter, r *http.Request) {
T := Printer(r.Context())
t := newTemplate(a.templateFS, "index.html")
w.Header().Set("content-type", "text/html")
a.addExpireHeaders(w, time.Minute*5)
type Page struct {
Page string
Title string
Sessions []Session
}
body := Page{
Page: "search",
Title: T.Sprintf("NYC Council Legislation Search"),
Sessions: Sessions[:4],
}
err := t.ExecuteTemplate(w, "index.html", body)
if err != nil {
log.Print(err)
http.Error(w, "Internal Server Error", 500)
return
}
}