gziphandler:将中间件转换为gzip HTTP响应

时间:2021-02-03 14:26:45
【文件属性】:
文件名称:gziphandler:将中间件转换为gzip HTTP响应
文件大小:54KB
文件格式:ZIP
更新时间:2021-02-03 14:26:45
go golang http middleware gzip Gzip处理程序 这是一个很小的Go包,它包装HTTP处理程序以透明地gzip响应主体,以支持响应主体。 尽管通常将其留给反向代理(例如nginx或Varnish)较为简单,但在不希望使用此软件包时,它很有用。 安装 go get -u github.com/NYTimes/gziphandler 用法 使用任何处理程序(实现http.Handler接口的对象)调用GzipHandler ,它将返回一个新的处理程序,该处理程序对响应进行gzip处理。 例如: package main import ( "io" "net/http" "github.com/NYTimes/gziphandler" ) func main () { withoutGz := http . HandlerFunc ( func ( w http. ResponseWriter , r * http. Request ) { w . Header (). Set ( "Content-Type" , "text/plain" ) io . WriteString ( w , "Hello,
【文件预览】:
gziphandler-master
----.gitignore(6B)
----go.mod(91B)
----gzip_test.go(24KB)
----gzip_go18.go(1KB)
----gzip_go18_test.go(2KB)
----.travis.yml(115B)
----CONTRIBUTING.md(1KB)
----gzip.go(16KB)
----CODE_OF_CONDUCT.md(7KB)
----LICENSE(11KB)
----go.sum(608B)
----testdata()
--------benchmark.json(128KB)
----README.md(1KB)

网友评论