minify

package module
v0.0.0-...-76f571f Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2022 License: LGPL-2.1 Imports: 11 Imported by: 0

README

gin-minify

gin middleware to minify css/js/json/svg/xml data.

Notice: It's an early stage library, please DO NOT use in production. PR is warmly welcome.

Usage

import 	"github.com/missdeer/gin-minify"

func main() {
	r := gin.Default()

	r.Use(minify.Minify(minify.IgnoreHTML())) // HTML can't work properly due to Transfer-Encoding: chunked
    ...
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultExcludedExtentions = NewExcludedExtensions([]string{
		".png", ".gif", ".jpeg", ".jpg",
	})
	DefaultOptions = &Options{
		ExcludedExtensions: DefaultExcludedExtentions,
	}
)

Functions

func Minify

func Minify(options ...Option) gin.HandlerFunc

Types

type ExcludedExtensions

type ExcludedExtensions map[string]bool

Using map for better lookup performance

func NewExcludedExtensions

func NewExcludedExtensions(extensions []string) ExcludedExtensions

func (ExcludedExtensions) Contains

func (e ExcludedExtensions) Contains(target string) bool

type ExcludedPathesRegexs

type ExcludedPathesRegexs []*regexp.Regexp

func NewExcludedPathesRegexs

func NewExcludedPathesRegexs(regexs []string) ExcludedPathesRegexs

func (ExcludedPathesRegexs) Contains

func (e ExcludedPathesRegexs) Contains(requestURI string) bool

type ExcludedPaths

type ExcludedPaths []string

func NewExcludedPaths

func NewExcludedPaths(paths []string) ExcludedPaths

func (ExcludedPaths) Contains

func (e ExcludedPaths) Contains(requestURI string) bool

type Option

type Option func(*Options)

func IgnoreCSS

func IgnoreCSS() Option

func IgnoreHTML

func IgnoreHTML() Option

func IgnoreJS

func IgnoreJS() Option

func IgnoreJSON

func IgnoreJSON() Option

func IgnoreSVG

func IgnoreSVG() Option

func IgnoreXML

func IgnoreXML() Option

func WithExcludedExtensions

func WithExcludedExtensions(args []string) Option

func WithExcludedPaths

func WithExcludedPaths(args []string) Option

func WithExcludedPathsRegexs

func WithExcludedPathsRegexs(args []string) Option

type Options

type Options struct {
	ExcludedExtensions   ExcludedExtensions
	ExcludedPaths        ExcludedPaths
	ExcludedPathesRegexs ExcludedPathesRegexs
	IgnoreHTML           bool
	IgnoreCSS            bool
	IgnoreJS             bool
	IgnoreJSON           bool
	IgnoreSVG            bool
	IgnoreXML            bool
}

Jump to

Keyboard shortcuts

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