Documentation ¶
Overview ¶
Package gowebcompress applies top compression hueristics to offer a dynamic (for APIs) and Static http middleware to accelerate your server.
Index ¶
- Variables
- func FS(w io.Writer, opts CacheOpts, origPath string) (handled bool)
- func Handler(w http.ResponseWriter, req *http.Request) (newWriter http.ResponseWriter, complete func())
- func Middleware(handler http.Handler) http.Handler
- func OSCreate(abspath string) (io.WriteCloser, error)
- type CacheInfo
- type CacheOpts
- type CreateFile
- type Levels
- type OSFSStat
Constants ¶
This section is empty.
Variables ¶
var DynamicLevels = Levels{2, 2}
var StaticLevels = Levels{6, 4}
Functions ¶
func FS ¶
FS is a convenience function for informing the cacher that a static file is being served and the compressed contents can be cached there. It requires the Middleware to have ran & fs must support StatFS. Use in handler (for static/foo.txt):
if gowebcompress.FS(w, os.DirFS("/"), os.Create, "static/foo.txt") { return; // Bytes sent from Disk Cache }
serveFile("static/foo.txt")
func Handler ¶
func Handler(w http.ResponseWriter, req *http.Request) (newWriter http.ResponseWriter, complete func())
Handler makes it easy for wrapping for custom routers (ex: Gin)
func Middleware ¶
Middleware for compression supporting Brotoli & Gzip. Uses a static-compiled Brotoli library (no external dep). Have a compiler ready. Optimized for low CPU usage: 80kb/ms today, or change DynamicLevels / StaticLevels.
Types ¶
type CreateFile ¶
type CreateFile func(path string) (io.WriteCloser, error)