gzip

package module
v0.0.0-...-a3e7177 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2018 License: MIT Imports: 8 Imported by: 0

README

GZIP gin's middleware

Build Status codecov Go Report Card GoDoc

Gin middleware to enable GZIP support.

Usage

Start using it

Download and install it:

$ go get github.com/gin-contrib/gzip

Import it in your code:

import "github.com/gin-contrib/gzip"
Canonical example:
package main

import (
	"fmt"
	"time"

	"github.com/gin-contrib/gzip"
	"github.com/gin-gonic/gin"
)

func main() {
	r := gin.Default()
	r.Use(gzip.Gzip(gzip.DefaultCompression))
	r.GET("/ping", func(c *gin.Context) {
		c.String(200, "pong "+fmt.Sprint(time.Now().Unix()))
	})

	// Listen and Server in 0.0.0.0:8080
	r.Run(":8080")
}

Documentation

Index

Constants

View Source
const (
	BestCompression    = gzip.BestCompression
	BestSpeed          = gzip.BestSpeed
	DefaultCompression = gzip.DefaultCompression
	NoCompression      = gzip.NoCompression

	HeaderContentEncoding = "Content-Encoding"
)

Variables

This section is empty.

Functions

func Gzip

func Gzip(level int) gin.HandlerFunc

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL