-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathxmux_test.go
More file actions
41 lines (34 loc) · 871 Bytes
/
Copy pathxmux_test.go
File metadata and controls
41 lines (34 loc) · 871 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 xmux
import (
"log"
"net/http"
"testing"
)
func home(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("home admin" + Var(r)["bbb"]))
}
func grouphome(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("grouphome" + Var(r)["name"] + "-" + Var(r)["age"]))
}
func adminGroup() *RouteGroup {
admin := NewRouteGroup().Prefix("test")
admin.Get("/admin/{bbb}", home)
admin.Get("/aaa/adf{re:([a-z]{1,4})sf([0-9]{0,10})sd: name, age}", grouphome)
return admin
}
func userGroup() *RouteGroup {
user := NewRouteGroup().Prefix("test")
user.Get("/group", grouphome)
user.AddGroup(adminGroup())
return user
}
func TestMain(t *testing.T) {
router := NewRouter()
router.AddGroup(Pprof())
router.EnableConnect = true
router.Get("/pp", home)
router.SetAddr(":9000")
router.AddGroup(userGroup())
router.DebugTpl()
log.Fatal(router.Run())
}