From b353029b746db76581060cde81683755f822da3f Mon Sep 17 00:00:00 2001 From: zstone12 <522089185@qq.com> Date: Mon, 4 Dec 2023 12:10:32 +0800 Subject: [PATCH] fix: func name (#16) --- gzip | 1 + gzip_test.go | 10 +++++----- options.go | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) create mode 160000 gzip diff --git a/gzip b/gzip new file mode 160000 index 0000000..d9ed26f --- /dev/null +++ b/gzip @@ -0,0 +1 @@ +Subproject commit d9ed26f9e294cfa50de7f41cf97237c29d4acdb5 diff --git a/gzip_test.go b/gzip_test.go index 4113f38..99610ca 100644 --- a/gzip_test.go +++ b/gzip_test.go @@ -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) @@ -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") }) @@ -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) }) @@ -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") }) @@ -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) diff --git a/options.go b/options.go index 7f6e6d1..80e3689 100644 --- a/options.go +++ b/options.go @@ -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 }