generated from bool64/go-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandler.go
32 lines (26 loc) · 849 Bytes
/
handler.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
package main
import (
"fmt"
"net/http"
)
func (r *userRepo) ServeHTTP(w http.ResponseWriter, _ *http.Request) {
_, _ = w.Write([]byte(`
<div>
<a href="/json-form/form.html?title=Create%20user&schemaName=` + r.schemaName + `&submitUrl=/users&submitMethod=POST&successStatus=201">Create user with dynamic form</a>
<br />
<a href="/create-user">Create user with static form</a>
</div>
<ul>
`))
for i, u := range r.list() {
_, _ = w.Write([]byte(fmt.Sprintf(`
<li> %s %s
<a href="/json-form/form.html?title=Edit%%20user&schemaName=`+r.schemaName+`&valueUrl=/user/%d.json&submitUrl=/user/%d.json&submitMethod=PUT&successStatus=204">Edit with dynamic form</a>
<a href="/edit-user/%d">Edit with static form</a><br />
</li>
`, u.FirstName, u.LastName, i+1, i+1, i+1)))
}
_, _ = w.Write([]byte(`
</ul>
`))
}