-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
63 lines (57 loc) · 1.49 KB
/
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
54
55
56
57
58
59
60
61
62
63
package main
import (
"JGee/JGee"
"fmt"
"log"
"net/http"
"time"
)
func onlyForV2() JGee.HandlerFunc {
return func(c *JGee.Context) {
fmt.Println("this is onlyForV2 func and c.index = ")
// Start timer
t := time.Now()
// if a server error occurred
//c.Fail(500, "Internal Server Error")
// Calculate resolution time
c.Next()
log.Printf("this is only ForV2 after next [%d] %s in %v for group v2", c.StatusCode, c.Req.RequestURI, time.Since(t))
}
}
func main() {
r := JGee.New()
r.Use(JGee.Logger()) // global midlleware
r.GET("/", func(c *JGee.Context) {
c.HTML(http.StatusOK, "<h1>Hello Gee</h1>")
})
//r.Use(JGee.Logger())
/*r.GET("/", func(c *JGee.Context) {
c.HTML(http.StatusOK, "<h1>Hello Gee</h1>")
})*/
v2 := r.Group("/v2")
v2.Use(onlyForV2())
{
/*v1.GET("/", func(c *JGee.Context) {
// expect /hello?name=geektutu
c.HTML(http.StatusOK, "<h1>Hello Gee</h1>")
})*/
v2.GET("/hello/:name", func(c *JGee.Context) {
//expect /hello?name=geektutu
fmt.Println("this is /hello/:name")
c.String(http.StatusOK, "hello %s, you're at %s\n", c.Query("name"), c.Path)
})
}
//v1 := r.Group("/v1")
//{
/*v1.GET("/", func(c *JGee.Context) {
// expect /hello?name=geektutu
c.HTML(http.StatusOK, "<h1>Hello Gee</h1>")
})*/
// v1.GET("/hello/", func(c *JGee.Context) {
// expect /hello?name=geektutu
// c.String(http.StatusOK, "hello %s, you're at %s\n", c.Query("name"), c.Path)
// })
// }*/
r.Run(":9999")
//fmt.Println(ParsePattern("/abc/*122/*abc"))
}