Skip to content

Commit b345d29

Browse files
committed
Address review feedback
1 parent 9bc5c30 commit b345d29

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

ctx.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,10 @@ func (c *DefaultCtx) Body() []byte {
370370
c.fasthttp.Request.SetBodyRaw(originalBody)
371371
}
372372
if err != nil {
373-
switch err {
374-
case ErrUnsupportedMediaType:
373+
switch {
374+
case errors.Is(err, ErrUnsupportedMediaType):
375375
_ = c.SendStatus(StatusUnsupportedMediaType) //nolint:errcheck // It is fine to ignore the error
376-
case ErrNotImplemented:
376+
case errors.Is(err, ErrNotImplemented):
377377
_ = c.SendStatus(StatusNotImplemented) //nolint:errcheck // It is fine to ignore the error
378378
}
379379
return []byte(err.Error())

ctx_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ func Test_Ctx_Body_With_Compression(t *testing.T) {
533533
encs := strings.Split(tCase.contentEncoding, ",")
534534
for _, enc := range encs {
535535
enc = strings.TrimSpace(enc)
536-
if strings.Contains(tCase.name, "invalid_deflate") && enc == "deflate" {
536+
if strings.Contains(tCase.name, "invalid_deflate") && enc == StrDeflate {
537537
continue
538538
}
539539
switch enc {
@@ -545,7 +545,7 @@ func Test_Ctx_Body_With_Compression(t *testing.T) {
545545
require.NoError(t, gz.Flush())
546546
require.NoError(t, gz.Close())
547547
tCase.body = b.Bytes()
548-
case "deflate":
548+
case StrDeflate:
549549
var b bytes.Buffer
550550
fl := zlib.NewWriter(&b)
551551
_, err := fl.Write(tCase.body)
@@ -625,7 +625,7 @@ func Benchmark_Ctx_Body_With_Compression(b *testing.B) {
625625
compressWriter: compressGzip,
626626
},
627627
{
628-
contentEncoding: "deflate",
628+
contentEncoding: StrDeflate,
629629
compressWriter: compressDeflate,
630630
},
631631
{
@@ -763,7 +763,7 @@ func Test_Ctx_Body_With_Compression_Immutable(t *testing.T) {
763763
encs := strings.Split(tCase.contentEncoding, ",")
764764
for _, enc := range encs {
765765
enc = strings.TrimSpace(enc)
766-
if strings.Contains(tCase.name, "invalid_deflate") && enc == "deflate" {
766+
if strings.Contains(tCase.name, "invalid_deflate") && enc == StrDeflate {
767767
continue
768768
}
769769
switch enc {
@@ -775,7 +775,7 @@ func Test_Ctx_Body_With_Compression_Immutable(t *testing.T) {
775775
require.NoError(t, gz.Flush())
776776
require.NoError(t, gz.Close())
777777
tCase.body = b.Bytes()
778-
case "deflate":
778+
case StrDeflate:
779779
var b bytes.Buffer
780780
fl := zlib.NewWriter(&b)
781781
_, err := fl.Write(tCase.body)
@@ -855,7 +855,7 @@ func Benchmark_Ctx_Body_With_Compression_Immutable(b *testing.B) {
855855
compressWriter: compressGzip,
856856
},
857857
{
858-
contentEncoding: "deflate",
858+
contentEncoding: StrDeflate,
859859
compressWriter: compressDeflate,
860860
},
861861
{

0 commit comments

Comments
 (0)