gzip

package
v0.0.0-...-4f29e57 Latest Latest
Warning

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

Go to latest
Published: May 25, 2015 License: MIT, MIT Imports: 3 Imported by: 0

README

gzip middleware for gin

This middleware comes from original gin-gonic middleware located in https://github.com/gin-gonic/contrib. Since gin does not reset ResponseWriter in context when overwritten, this middleware resolves issue by recovering original writer to the context.

package main

import (
	"fmt"
	"github.com/dogenzaka/gin-tools/gzip"
	"github.com/gin-gonic/gin"
	"time"
)

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

Overview

Package gzip middleware comes from github.com/gin-gonic/contrib/gzip Fixed response writer issue

Index

Constants

View Source
const (
	// BestCompression delegates from BestCompression of compress/gzip
	BestCompression = gogzip.BestCompression
	// BestSpeed delegates from BestSpeed of compress/gzip
	BestSpeed = gogzip.BestSpeed
	// DefaultCompression delegates from DefaultCompression of compress/gzip
	DefaultCompression = gogzip.DefaultCompression
	// NoCompression delegates from NoCompression of compress/gzip
	NoCompression = gogzip.NoCompression
)

Variables

This section is empty.

Functions

func Gzip

func Gzip(level int) gin.HandlerFunc

Gzip compresses a response of http

Types

This section is empty.

Jump to

Keyboard shortcuts

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