mirror of
https://github.com/gofiber/fiber.git
synced 2025-02-21 20:33:08 +00:00
Update package names
This commit is contained in:
parent
4dead8d6d3
commit
5e797e9ef0
@ -4,8 +4,8 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/gofiber/fiber"
|
||||
"github.com/valyala/fasthttp"
|
||||
fiber "github.com/gofiber/fiber"
|
||||
fasthttp "github.com/valyala/fasthttp"
|
||||
)
|
||||
|
||||
// CompressConfig defines the config for Compress middleware.
|
||||
@ -67,16 +67,16 @@ func CompressWithConfig(config CompressConfig) fiber.Handler {
|
||||
|
||||
func compress(config CompressConfig) fiber.Handler {
|
||||
// Init middleware settings
|
||||
var compress fasthttp.RequestHandler
|
||||
var compressHandler fasthttp.RequestHandler
|
||||
switch config.Level {
|
||||
case -1: // Disabled
|
||||
compress = fasthttp.CompressHandlerBrotliLevel(func(c *fasthttp.RequestCtx) {}, fasthttp.CompressBrotliNoCompression, fasthttp.CompressNoCompression)
|
||||
compressHandler = fasthttp.CompressHandlerBrotliLevel(func(c *fasthttp.RequestCtx) {}, fasthttp.CompressBrotliNoCompression, fasthttp.CompressNoCompression)
|
||||
case 1: // Best speed
|
||||
compress = fasthttp.CompressHandlerBrotliLevel(func(c *fasthttp.RequestCtx) {}, fasthttp.CompressBrotliBestSpeed, fasthttp.CompressBestSpeed)
|
||||
compressHandler = fasthttp.CompressHandlerBrotliLevel(func(c *fasthttp.RequestCtx) {}, fasthttp.CompressBrotliBestSpeed, fasthttp.CompressBestSpeed)
|
||||
case 2: // Best compression
|
||||
compress = fasthttp.CompressHandlerBrotliLevel(func(c *fasthttp.RequestCtx) {}, fasthttp.CompressBrotliBestCompression, fasthttp.CompressBestCompression)
|
||||
compressHandler = fasthttp.CompressHandlerBrotliLevel(func(c *fasthttp.RequestCtx) {}, fasthttp.CompressBrotliBestCompression, fasthttp.CompressBestCompression)
|
||||
default: // Default
|
||||
compress = fasthttp.CompressHandlerBrotliLevel(func(c *fasthttp.RequestCtx) {}, fasthttp.CompressBrotliDefaultCompression, fasthttp.CompressDefaultCompression)
|
||||
compressHandler = fasthttp.CompressHandlerBrotliLevel(func(c *fasthttp.RequestCtx) {}, fasthttp.CompressBrotliDefaultCompression, fasthttp.CompressDefaultCompression)
|
||||
}
|
||||
// Return handler
|
||||
return func(c *fiber.Ctx) {
|
||||
@ -88,6 +88,6 @@ func compress(config CompressConfig) fiber.Handler {
|
||||
// Middleware logic...
|
||||
c.Next()
|
||||
// Compress response
|
||||
compress(c.Fasthttp)
|
||||
compressHandler(c.Fasthttp)
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/gofiber/fiber"
|
||||
fiber "github.com/gofiber/fiber"
|
||||
)
|
||||
|
||||
// Middleware types
|
||||
|
@ -11,9 +11,9 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/gofiber/fiber"
|
||||
"github.com/gofiber/utils"
|
||||
"github.com/valyala/bytebufferpool"
|
||||
fiber "github.com/gofiber/fiber"
|
||||
utils "github.com/gofiber/utils"
|
||||
bytebufferpool "github.com/valyala/bytebufferpool"
|
||||
)
|
||||
|
||||
// Middleware types
|
||||
|
@ -4,8 +4,8 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/gofiber/fiber"
|
||||
"github.com/gofiber/utils"
|
||||
fiber "github.com/gofiber/fiber"
|
||||
utils "github.com/gofiber/utils"
|
||||
)
|
||||
|
||||
// Middleware types
|
||||
|
Loading…
x
Reference in New Issue
Block a user