-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
31 lines (29 loc) · 800 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
package main
import (
"kvStore/gee"
"net/http"
)
func main() {
r := gee.New()
r.GET("/", func(c *gee.Context) {
c.HTML(http.StatusOK, "<h1>yexiaoyu's golang template</h1>")
})
r.GET("/hello", func(c *gee.Context) {
// expect /hello?name=yexiaoyu
c.String(http.StatusOK, "hello %s, you're at %s\n", c.Query("name"), c.Path)
})
r.GET("/hello/:name", func(c *gee.Context) {
// expect /hello/yexiaoyu
c.String(http.StatusOK, "hello %s, you're at %s\n", c.Param("name"), c.Path)
})
r.GET("/assets/*filepath", func(c *gee.Context) {
c.JSON(http.StatusOK, gee.Cont{"filepath": c.Param("filepath")})
})
r.POST("/login", func(c *gee.Context) {
c.JSON(http.StatusOK, gee.Cont{
"username": c.PostForm("username"),
"password": c.PostForm("password"),
})
})
r.Run(":9999")
}