Skip to content

Commit 4fac025

Browse files
committed
Rename package from pulse-router to pulse
1 parent 332a0c6 commit 4fac025

File tree

7 files changed

+47
-24
lines changed

7 files changed

+47
-24
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# Pulse Routing (In Development)
1+
# Pulse Web framework (In Development)
22

3-
Pulse Routing is a routing package for the [Pulse Framework](https://github.com/gopulse/pulse).
3+
Pulse is a web framework for the Go programming language. It is a lightweight framework that is easy to use and easy to learn. It is designed to be a simple and elegant solution to building web applications and APIs.

context.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package routing
1+
package pulse
22

33
import (
44
"bytes"
5-
"github.com/gopulse/pulse-router/utils"
5+
"github.com/gopulse/pulse/utils"
66
"github.com/valyala/fasthttp"
77
"time"
88
)
@@ -164,3 +164,8 @@ func (c *Context) GetHeader(key string) string {
164164
func (c *Context) Accepts(types ...string) string {
165165
return ""
166166
}
167+
168+
// Status sets the response status code.
169+
func (c *Context) Status(code int) {
170+
c.RequestCtx.Response.SetStatusCode(code)
171+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module github.com/gopulse/pulse-router
1+
module github.com/gopulse/pulse
22

33
go 1.19
44

middleware.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package routing
1+
package pulse
22

33
type MiddlewareFunc func(handler Handler) Handler
44

route.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package routing
1+
package pulse
22

3-
import "github.com/gopulse/pulse-router/constants"
3+
import "github.com/gopulse/pulse/constants"
44

55
type route struct {
66
method string

router.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package routing
1+
package pulse
22

33
import (
44
"fmt"
@@ -29,7 +29,7 @@ type Static struct {
2929
CacheDuration time.Duration
3030
}
3131

32-
func New() *Router {
32+
func NewRouter() *Router {
3333
return &Router{
3434
routes: make(map[string][]*Route),
3535
middlewares: make(map[string][]Middleware),

router_test.go

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,55 @@
1-
package routing
1+
package pulse
22

33
import (
44
"fmt"
5-
"github.com/valyala/fasthttp"
65
"testing"
76
"time"
87
)
98

9+
func init() {
10+
app = New(Config{
11+
AppName: "Test App",
12+
Network: "tcp",
13+
})
14+
}
15+
1016
func TestRouterHandler(t *testing.T) {
11-
router := New()
17+
router := NewRouter()
18+
19+
app.router = router
1220

1321
router.Get("/users/*", func(ctx *Context) error {
1422
ctx.String("hello")
1523
return nil
1624
})
1725

18-
err := fasthttp.ListenAndServe(":8083", RouterHandler(router))
26+
err := app.Run(":8082")
1927
if err != nil {
2028
return
2129
}
2230
}
2331

2432
func TestCORSMiddleware(t *testing.T) {
25-
router := New()
33+
router := NewRouter()
34+
35+
app.router = router
2636

2737
router.Get("/", func(ctx *Context) error {
2838
return nil
2939
})
3040

3141
router.Use("GET", CORSMiddleware())
3242

33-
err := fasthttp.ListenAndServe(":8083", RouterHandler(router))
43+
err := app.Run(":8082")
3444
if err != nil {
3545
return
3646
}
3747
}
3848

3949
func TestContext_SetCookie(t *testing.T) {
40-
router := New()
50+
router := NewRouter()
51+
52+
app.router = router
4153

4254
router.Get("/", func(ctx *Context) error {
4355
cookie := Cookie{
@@ -56,44 +68,50 @@ func TestContext_SetCookie(t *testing.T) {
5668
return nil
5769
})
5870

59-
err := fasthttp.ListenAndServe(":8083", RouterHandler(router))
71+
err := app.Run(":8082")
6072
if err != nil {
6173
return
6274
}
6375
}
6476

6577
func TestContext_GetCookie(t *testing.T) {
66-
router := New()
78+
router := NewRouter()
79+
80+
app.router = router
6781

6882
router.Get("/", func(ctx *Context) error {
6983
cookie := ctx.GetCookie("test")
7084
ctx.String(cookie)
7185
return nil
7286
})
7387

74-
err := fasthttp.ListenAndServe(":8083", RouterHandler(router))
88+
err := app.Run(":8082")
7589
if err != nil {
7690
return
7791
}
7892
}
7993

8094
func TestContext_SetHeader(t *testing.T) {
81-
router := New()
95+
router := NewRouter()
96+
97+
app.router = router
8298

8399
router.Get("/", func(ctx *Context) error {
84100
ctx.SetHeader("Test Header", "test header value")
85101
fmt.Println(ctx.GetHeader("test"))
86102
return nil
87103
})
88104

89-
err := fasthttp.ListenAndServe(":8083", RouterHandler(router))
105+
err := app.Run(":8082")
90106
if err != nil {
91107
return
92108
}
93109
}
94110

95111
func TestRouter_Static(t *testing.T) {
96-
router := New()
112+
router := NewRouter()
113+
114+
app.router = router
97115

98116
router.Static("/", "./static", &Static{
99117
Compress: true,
@@ -102,7 +120,7 @@ func TestRouter_Static(t *testing.T) {
102120
CacheDuration: 24 * time.Hour,
103121
})
104122

105-
err := fasthttp.ListenAndServe(":8083", RouterHandler(router))
123+
err := app.Run(":8082")
106124
if err != nil {
107125
return
108126
}

0 commit comments

Comments
 (0)