Skip to content

Commit

Permalink
fix: func name (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
zstone12 authored Dec 4, 2023
1 parent 095dd13 commit b353029
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions gzip
Submodule gzip added at d9ed26
10 changes: 5 additions & 5 deletions gzip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func TestDecompressGzip(t *testing.T) {
}
gz.Close()
router := route.NewEngine(config.NewOptions([]config.Option{}))
router.Use(Gzip(DefaultCompression, WithDecompressFn(DefaultDecompressMiddleware)))
router.Use(Gzip(DefaultCompression, WithDecompressFn(DefaultDecompressHandle)))
router.POST("/", func(ctx context.Context, c *app.RequestContext) {
if v := c.Request.Header.Get("Content-Encoding"); v != "" {
t.Errorf("unexpected `Content-Encoding`: %s header", v)
Expand All @@ -196,7 +196,7 @@ func TestDecompressGzip(t *testing.T) {

func TestDecompressGzipWithEmptyBody(t *testing.T) {
router := route.NewEngine(config.NewOptions([]config.Option{}))
router.Use(Gzip(DefaultCompression, WithDecompressFn(DefaultDecompressMiddleware)))
router.Use(Gzip(DefaultCompression, WithDecompressFn(DefaultDecompressHandle)))
router.POST("/", func(ctx context.Context, c *app.RequestContext) {
c.String(200, "ok")
})
Expand All @@ -213,7 +213,7 @@ func TestDecompressGzipWithEmptyBody(t *testing.T) {

func TestDecompressGzipWithSkipFunc(t *testing.T) {
router := route.NewEngine(config.NewOptions([]config.Option{}))
router.Use(Gzip(DefaultCompression, WithDecompressFn(DefaultDecompressMiddleware)))
router.Use(Gzip(DefaultCompression, WithDecompressFn(DefaultDecompressHandle)))
router.POST("/", func(ctx context.Context, c *app.RequestContext) {
c.SetStatusCode(200)
})
Expand All @@ -230,7 +230,7 @@ func TestDecompressGzipWithSkipFunc(t *testing.T) {

func TestDecompressGzipWithIncorrectData(t *testing.T) {
router := route.NewEngine(config.NewOptions([]config.Option{}))
router.Use(Gzip(DefaultCompression, WithDecompressFn(DefaultDecompressMiddleware)))
router.Use(Gzip(DefaultCompression, WithDecompressFn(DefaultDecompressHandle)))
router.POST("/", func(ctx context.Context, c *app.RequestContext) {
c.String(200, "ok")
})
Expand Down Expand Up @@ -409,7 +409,7 @@ func TestDecompressGzipForClient(t *testing.T) {
c.Header("Content-Length", strconv.Itoa(len(testResponse)))
c.String(200, testResponse)
})
h.Use(Gzip(DefaultCompression, WithDecompressFn(DefaultDecompressMiddleware)))
h.Use(Gzip(DefaultCompression, WithDecompressFn(DefaultDecompressHandle)))
go h.Spin()

time.Sleep(time.Second)
Expand Down
2 changes: 1 addition & 1 deletion options.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (e ExcludedPaths) Contains(requestURI string) bool {
return false
}

func DefaultDecompressMiddleware(ctx context.Context, c *app.RequestContext) {
func DefaultDecompressHandle(ctx context.Context, c *app.RequestContext) {
if len(c.Request.Body()) <= 0 {
return
}
Expand Down

0 comments on commit b353029

Please sign in to comment.