-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
38 lines (26 loc) · 804 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
package main
import (
"Ksana/controller"
"Ksana/router"
"fmt"
"log"
"net/http"
)
// Handler 带装饰的处理器
var Handler = controller.Handler
func main() {
app := new(router.Router)
app.Get("/", func(ctx controller.Context) {
fmt.Fprintf(ctx.Res, "Hello World")
})
app.Post("/login", controller.Login)
app.Get("/authorizationCheck", controller.AuthorizationCheck)
app.Post("/post/add", Handler(controller.AddPost, controller.AuthorCheck))
app.Post("/post/update/:pID", Handler(controller.UpdatePost, controller.AuthorCheck))
app.Get("/post/get/:pID", controller.GetPost)
app.Get("/tags/get", controller.GetTags)
app.Get("/post/getByTag/:tag", controller.GetPostsByTag)
if err := http.ListenAndServe(":9090", app); err != nil {
log.Fatal("ListenAndServe: ", err)
}
}