-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandleLocal.go
More file actions
41 lines (35 loc) · 855 Bytes
/
Copy pathhandleLocal.go
File metadata and controls
41 lines (35 loc) · 855 Bytes
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
package main
import (
"net/http"
"strconv"
"github.com/r-malon/sgaf/db"
)
func createLocal(w http.ResponseWriter, r *http.Request) error {
if r.FormValue("nome") == "" {
return nil
}
return q.CreateLocal(ctx, r.FormValue("nome"))
}
func listLocals(w http.ResponseWriter, r *http.Request) error {
l, err := q.ListLocals(ctx)
if err != nil {
return err
}
return tmpl.ExecuteTemplate(w, "listLocals", l)
}
func updateLocal(w http.ResponseWriter, r *http.Request) error {
if r.FormValue("nome") == "" {
return nil
}
return q.UpdateLocal(ctx, db.UpdateLocalParams{
r.FormValue("nome"),
first(strconv.ParseInt(r.PathValue("id"), 10, 64)),
})
}
func deleteLocal(w http.ResponseWriter, r *http.Request) error {
id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
if err != nil {
return err
}
return q.DeleteLocal(ctx, id)
}