Compress
This package provides a middleware for the Go's net/http (or other compatible routers) that compresses the response using brotli or gzip compression algorithms.
Install / Use
/learn @go-swiss/CompressREADME
Compression Middleware
This package provides a middleware for the Go's net/http (or other compatible routers) that compresses the response using brotli or gzip compression algorithms.
It depends only on https://github.com/andybalholm/brotli.
Usage
-
Import the package
import "github.com/go-swiss/compress" -
Add
compress.Middlewareto your router.
With net/http
import (
"net/http"
"github.com/go-swiss/compress"
)
func main() {
mux := http.NewServeMux()
mux.HandleFunc("/", HomeHandler)
http.ListenAndServe(":8080", compress.Middleware(mux))
}
With gorilla/mux
import (
"net/http"
"github.com/go-swiss/compress"
"github.com/gorilla/mux"
)
func main() {
r := mux.NewRouter()
r.Use(compress.Middleware)
r.HandleFunc("/", HomeHandler)
http.ListenAndServe(":8080", r)
}
With go-chi/chi
import (
"net/http"
"github.com/go-chi/chi/v5"
"github.com/go-swiss/compress"
)
func main() {
r := chi.NewRouter()
r.Use(compress.Middleware)
r.Get("/", HomeHandler)
http.ListenAndServe(":8080", r)
}
Related Skills
node-connect
347.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
xurl
347.9kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
frontend-design
108.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
