gzip

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: MIT Imports: 7 Imported by: 1

README

gzip

GitHub Workflow Status Codecov GoDoc Sourcegraph

Package gzip is a middleware that provides gzip compression to responses for Flamego.

Installation

The minimum requirement of Go is 1.18.

go get github.com/flamego/gzip

Getting started

package main

import (
	"github.com/flamego/flamego"
	"github.com/flamego/gzip"
)

func main() {
	f := flamego.Classic()
	f.Use(gzip.Gzip())
	f.Get("/", func() string {
		return "ok"
	})
	f.Run()
}

Getting help

License

This project is under the MIT License. See the LICENSE file for the full license text.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Gzip

func Gzip(options ...Options) flamego.Handler

Gzip returns a Handler that adds gzip compression to all requests. Make sure to include the gzip middleware above other middleware that alter the response body (like the render middleware).

Types

type Options

type Options struct {
	// CompressionLevel indicates the compression level, possible values are between
	// 0 to 9 (from no compression to best compression). Default is 4.
	CompressionLevel int
}

Options represents a struct for specifying configuration options for the gzip middleware.

Jump to

Keyboard shortcuts

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