Skip to content

Commit 3595bd6

Browse files
committed
Refactor init and add compression support.
- Break to `/v2` to introduce `Options{}` that's pass to lib init. - Add `CompressOptions{}` to enable zstd|br|gzip|deflate auto-compression support offered by fasthttp.
1 parent 9a0624f commit 3595bd6

File tree

16 files changed

+186
-48
lines changed

16 files changed

+186
-48
lines changed

.github/workflows/go-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
test:
88
strategy:
99
matrix:
10-
go: ["1.21", "1.20", "1.18", "1.19"]
10+
go: ["1.21"]
1111

1212
runs-on: ubuntu-20.04
1313

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ write HTTP servers. It enables:
2323
## Install
2424

2525
```bash
26-
go get -u github.com/zerodha/fastglue
26+
go get -u github.com/zerodha/fastglue/v2
2727
```
2828

2929
## Usage
3030

3131
```go
32-
import "github.com/zerodha/fastglue"
32+
import "github.com/zerodha/fastglue/v2"
3333
```
3434

3535
## Examples

custom.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ type Envelope struct {
3131

3232
// NewGlue creates and returns a new instance of Fastglue with custom error
3333
// handlers pre-bound.
34-
func NewGlue() *Fastglue {
35-
f := New()
34+
func NewGlue(o Options) *Fastglue {
35+
f := New(o)
3636
f.Router.MethodNotAllowed = BadMethodHandler
3737
f.Router.NotFound = NotFoundHandler
3838
f.Router.SaveMatchedRoutePath = true

examples/before-after/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"time"
99

1010
"github.com/valyala/fasthttp"
11-
"github.com/zerodha/fastglue"
11+
"github.com/zerodha/fastglue/v2"
1212
)
1313

1414
var (
@@ -18,7 +18,7 @@ var (
1818
func main() {
1919
flag.Parse()
2020

21-
g := fastglue.New()
21+
g := fastglue.New(fastglue.Options{})
2222
g.Before(setTime)
2323
g.After(calculateTime)
2424
g.GET("/", handleIndex)

examples/decode/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"time"
88

99
"github.com/valyala/fasthttp"
10-
"github.com/zerodha/fastglue"
10+
"github.com/zerodha/fastglue/v2"
1111
)
1212

1313
var (
@@ -17,7 +17,7 @@ var (
1717
func main() {
1818
flag.Parse()
1919

20-
g := fastglue.New()
20+
g := fastglue.New(fastglue.Options{})
2121
g.GET("/", handleIndex)
2222

2323
s := &fasthttp.Server{

examples/example.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"time"
66

77
"github.com/valyala/fasthttp"
8-
"github.com/zerodha/fastglue"
8+
"github.com/zerodha/fastglue/v2"
99
)
1010

1111
// App is the global config "context" that'll be injected into every Request.

examples/graceful/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"time"
1010

1111
"github.com/valyala/fasthttp"
12-
"github.com/zerodha/fastglue"
12+
"github.com/zerodha/fastglue/v2"
1313
)
1414

1515
var (
@@ -19,7 +19,7 @@ var (
1919
func main() {
2020
flag.Parse()
2121

22-
g := fastglue.New()
22+
g := fastglue.New(fastglue.Options{})
2323
g.ServeStatic("/{filepath:*}", ".", true)
2424

2525
s := &fasthttp.Server{

examples/helloworld/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"time"
88

99
"github.com/valyala/fasthttp"
10-
"github.com/zerodha/fastglue"
10+
"github.com/zerodha/fastglue/v2"
1111
)
1212

1313
var (
@@ -17,7 +17,7 @@ var (
1717
func main() {
1818
flag.Parse()
1919

20-
g := fastglue.New()
20+
g := fastglue.New(fastglue.Options{})
2121
g.GET("/", handleHelloWorld)
2222

2323
s := &fasthttp.Server{

examples/middleware/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"time"
1010

1111
"github.com/valyala/fasthttp"
12-
"github.com/zerodha/fastglue"
12+
"github.com/zerodha/fastglue/v2"
1313
)
1414

1515
var (
@@ -19,7 +19,7 @@ var (
1919
func main() {
2020
flag.Parse()
2121

22-
g := fastglue.New()
22+
g := fastglue.New(fastglue.Options{})
2323
g.GET("/", auth(validateAll(handleGetAll)))
2424
g.PUT("/", auth(fastglue.ReqLenParams(validate(handleMiddleware), map[string]int{"a": 5, "b": 5})))
2525
g.POST("/", auth(fastglue.ReqParams(validate(handleMiddleware), []string{"a", "b"})))

examples/path/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"time"
99

1010
"github.com/valyala/fasthttp"
11-
"github.com/zerodha/fastglue"
11+
"github.com/zerodha/fastglue/v2"
1212
)
1313

1414
var (
@@ -18,7 +18,7 @@ var (
1818
func main() {
1919
flag.Parse()
2020

21-
g := fastglue.New()
21+
g := fastglue.New(fastglue.Options{})
2222
g.GET("/", handleIndex)
2323
g.GET("/{name:^[a-zA-Z]+$}", handleIndex)
2424

0 commit comments

Comments
 (0)