Skip to content

Commit 8e8c556

Browse files
authored
export group struct fields (#7)
1 parent bb9f731 commit 8e8c556

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

group.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,50 @@ package pulse
33
import "fmt"
44

55
type Group struct {
6-
prefix string
7-
router *Router
6+
Prefix string
7+
Router *Router
88
}
99

1010
func (g *Group) Group(prefix string) *Group {
1111
return &Group{
12-
prefix: g.prefix + prefix,
13-
router: g.router,
12+
Prefix: g.Prefix + prefix,
13+
Router: g.Router,
1414
}
1515
}
1616

1717
func (g *Group) Use(middleware Middleware) {
18-
g.router.Use(g.prefix, middleware)
18+
g.Router.Use(g.Prefix, middleware)
1919
}
2020

2121
func (g *Group) GET(path string, handlers ...Handler) {
22-
fmt.Println(g.prefix + path)
23-
g.router.Get(g.prefix+path, handlers...)
22+
fmt.Println(g.Prefix + path)
23+
g.Router.Get(g.Prefix+path, handlers...)
2424
}
2525

2626
func (g *Group) POST(path string, handlers ...Handler) {
27-
g.router.Post(g.prefix+path, handlers...)
27+
g.Router.Post(g.Prefix+path, handlers...)
2828
}
2929

3030
func (g *Group) PUT(path string, handlers ...Handler) {
31-
g.router.Put(g.prefix+path, handlers...)
31+
g.Router.Put(g.Prefix+path, handlers...)
3232
}
3333

3434
func (g *Group) DELETE(path string, handlers ...Handler) {
35-
g.router.Delete(g.prefix+path, handlers...)
35+
g.Router.Delete(g.Prefix+path, handlers...)
3636
}
3737

3838
func (g *Group) PATCH(path string, handlers ...Handler) {
39-
g.router.Patch(g.prefix+path, handlers...)
39+
g.Router.Patch(g.Prefix+path, handlers...)
4040
}
4141

4242
func (g *Group) OPTIONS(path string, handlers ...Handler) {
43-
g.router.Options(g.prefix+path, handlers...)
43+
g.Router.Options(g.Prefix+path, handlers...)
4444
}
4545

4646
func (g *Group) HEAD(path string, handlers ...Handler) {
47-
g.router.Head(g.prefix+path, handlers...)
47+
g.Router.Head(g.Prefix+path, handlers...)
4848
}
4949

5050
func (g *Group) Static(path, root string, config *Static) {
51-
g.router.Static(g.prefix+path, root, config)
51+
g.Router.Static(g.Prefix+path, root, config)
5252
}

group_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import "testing"
55
func TestRouter_Group(t *testing.T) {
66
router := NewRouter()
77
api := &Group{
8-
prefix: "/api",
9-
router: router,
8+
Prefix: "/api",
9+
Router: router,
1010
}
1111
v1 := api.Group("/v1")
1212
v1.GET("/users", func(ctx *Context) error {

0 commit comments

Comments
 (0)