New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃敟 Support GZip / Deflate #181
Comments
@hyingreborn, we have the option to disable gzipping for the |
I want gzip to work in my custom path锛宯ot only static files锛宖or example // gzip work in static path
app.Static("/app/", "./public/")
app.Use("/app", gzip())
// gzip work in api module
app := app.Group("/api", gzip())
//... |
@hyingreborn after Fiber @Fenny good idea to exclude |
I will use these two middleware when developing with gin, hoping to provide you with inspiration |
Thanks @hyingreborn for your suggestion, we will release a middleware folder soon and I will take a look if a gzipping middleware is possible with fasthttp! |
Hi guys Can I help you? I wish this challenge. For context about it. app.Static("/app/", "./public/")
app.Use("/app", fiber.gzip())
app := app.Group("/api", fiber.gzip()) See ya |
I saw now and FastHTTP have a compress gzip So, we should use func Gzip(c *fiber.Ctx) {
c.Set("Content-Encoding", "gzip")
c.Next()
}
app.Group("/api", gzip) Well, I believe that is possible using gzip on Fiber then I liked this approach to create a package for our middlewares. Can we create a todo list to implement these middlewares? I can't test this approach now, when possible I'll test. see ya |
I currently got the compression working, here is my proposal for func main() {
app := fiber.New(&fiber.Settings{
Compression: true, // global compression enabled
})
app.Get("/", func(c *fiber.Ctx) {
c.Send("Hello, World!") // compressed
})
app.Get("/demo", func(c *fiber.Ctx) {
c.Compress(false)
c.Send("hello, World!") // not compressed
})
}
func main() {
app := fiber.New() // compression disabled by default
app.Get("/", func(c *fiber.Ctx) {
c.Compress()
c.Send("Hello, World!") // compressed
})
app.Get("/demo", func(c *fiber.Ctx) {
c.Send("hello, World!") // not compressed
})
}
// Write own middleware
func gzip(c *fiber.Ctx) {
c.Compress()
c.Next()
}
func main() {
app := fiber.New() // compression disabled by default
app.Get("/", gzip, func(c *fiber.Ctx) {
c.Send("Hello, World!") // compressed
})
app.Get("/demo", func(c *fiber.Ctx) {
c.Send("hello, World!") // not compressed
})
} @renanbastos93, @hyingreborn, @koddr, let me know what you guys think. |
Added in |
Is your feature request related to a problem?
Now, the gzip is built in Static()锛宻o I can't customize which paths to open gzip and which file sizes to open gzip
Describe the solution you'd like
In my project锛宨 need open gzip for staticfiles锛宎t the same time, i want open gzip for restful api module(when the response is bigger than 4kb)
Describe alternatives you've considered
gzip be removed from Static() and exist as a official middleware
Additional context
The text was updated successfully, but these errors were encountered: