zitn / compress

gin compress middleware all in one

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

compress

Go Report Card

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

package main

import (
    "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
anargu/gin-brotli

About

gin compress middleware all in one

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Go 100.0%