Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zitn/compress
gin compress middleware all in one
https://github.com/zitn/compress
br compress deflate gin gzip
Last synced: about 1 month ago
JSON representation
gin compress middleware all in one
- Host: GitHub
- URL: https://github.com/zitn/compress
- Owner: zitn
- License: bsd-3-clause
- Created: 2022-02-10T06:48:55.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-02-15T04:38:45.000Z (over 2 years ago)
- Last Synced: 2024-10-01T09:06:03.215Z (about 2 months ago)
- Topics: br, compress, deflate, gin, gzip
- Language: Go
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README
# compress
[![Go Report Card](https://goreportcard.com/badge/github.com/zigitn/compress)](https://goreportcard.com/report/github.com/zigitn/compress)
an easy use compress middleware for gin.
# usage
Use `compress.New()` to create a compress middleware, it's accept an option, you can use `compress.UseAllBestSpeed()` to use all method and set them for best speed, or use `compress.UseAllBestCompression()`
to use all method but set them for best compression. if you want highly customizable, you can define your own `Option`.
By default, the methods order is `br`,`gzip`,`deflate`, if you like to change the order, you can define `Option` and change `Option.EnableMethods`.# example
```go
package mainimport (
"github.com/gin-gonic/gin"
"github.com/zigitn/compress"
)func main() {
router := gin.Default()
router.Use(compress.New(compress.UseAllBestSpeed()))
router.GET("/", func(c *gin.Context) {
c.String(200, "Hello World")
})
router.Run()
}
```# thanks
[gin-contrib/gzip](https://github.com/gin-contrib/gzip)
[anargu/gin-brotli](https://github.com/anargu/gin-brotli)