-
Notifications
You must be signed in to change notification settings - Fork 2
/
simpleHandler.go
47 lines (37 loc) · 905 Bytes
/
simpleHandler.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"net/http"
"text/template"
)
type TodoPageData struct {
PageTitle string
Todos []T
}
type T struct {
Name string
Position string
Office string
Age int32
}
func SimpleHandler(w http.ResponseWriter, r *http.Request) {
tmpl := template.Must(template.ParseFiles("templates/index.tmpl"))
data := todoPageDatafunc()
err := tmpl.Execute(w, data)
if err != nil {
errLog.Println(err)
}
}
func todoPageDatafunc() TodoPageData {
employees := []T{
T{"Airi Satou", "Accountant", "Tokyo", 33},
T{"Angelica Ramos", "Chief Executive Officer (CEO)", "London", 44},
T{"Ashton Cox", "Junior Technical Author", "San Francisco", 66},
T{"Brenden Wagner", "Software Engineer", "New York", 61},
T{"Bruno Nash", "Integration Specialist", "New York", 55},
}
data := TodoPageData{
PageTitle: "List of employees",
Todos: employees,
}
return data
}