brotli

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: 0

README

brotli

GitHub Workflow Status Codecov GoDoc Sourcegraph

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

Installation

The minimum requirement of Go is 1.18.

go get github.com/flamego/brotli

Getting started

package main

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

func main() {
	f := flamego.Classic()
	f.Use(brotli.Brotli())
	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 Brotli

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

Brotli returns a Handler that adds brotli compression to all requests. Make sure to include the brotli 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 11 (from best speed to best compression). Default is 5.
	CompressionLevel int
}

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

Jump to

Keyboard shortcuts

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