/
main.go
53 lines (45 loc) · 927 Bytes
/
main.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
48
49
50
51
52
53
package main
import (
"fmt"
"github.com/zenazn/goji"
"github.com/zenazn/goji/web"
"net/http"
)
type Todo struct {
id int
name string
IsDone bool
}
var mytodos []Todo
func init() {
t1 := Todo{
id: 1,
name: "Reading books",
IsDone: false,
}
t2 := Todo{
id: 2,
name: "playing cricket",
IsDone: false,
}
mytodos = append(mytodos, t1, t2)
}
func main() {
goji.Get("/todo", todos)
goji.Post("/todo/newTodo", newTodo)
goji.Get("/todo:id", getTodo)
goji.Put("/todo:id", putTodo)
goji.Delete("/todo:id", delTodo)
goji.Serve()
}
func todos(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, "%+v", mytodos)
}
func newTodo(w http.ResponseWriter, req *http.Request) {
}
func getTodo(c web.C, w http.ResponseWriter, req *http.Request) {
}
func putTodo(c web.C, w http.ResponseWriter, req *http.Request) {
}
func delTodo(c web.C, w http.ResponseWriter, req *http.Request) {
}