Minify 中间件由 tdewolff/minify 提供。

    1. import (
    2. "github.com/clevergo/clevergo"
    3. "github.com/tdewolff/minify/v2"
    4. "github.com/tdewolff/minify/v2/css"
    5. "github.com/tdewolff/minify/v2/html"
    6. "github.com/tdewolff/minify/v2/js"
    7. "github.com/tdewolff/minify/v2/svg"
    8. )
    1. m := minify.New()
    2. m.AddFunc("text/css", css.Minify)
    3. m.AddFunc("text/html", html.Minify)
    4. m.AddFunc("image/svg+xml", svg.Minify)
    5. m.AddFuncRegexp(regexp.MustCompile("^(application|text)/(x-)?(java|ecma)script$"), js.Minify)
    6. router.Use(clevergo.WrapHH(m.Middleware))