我使用 http.FileServer 作为静态服务器,但我想使用 gzip 压缩
现在的代码:
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
// Static file route
handle := http.FileServer(http.Dir("resource/dist"))
w.Header().Set("Content-Encoding", "gzip")
// ??? use gzip here?
handle.ServeHTTP(w, r)
})
并且响应标头已包含 gzip
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
Last-Modified: Tue, 28 Apr 2020 12:06:15 GMT
Date: Tue, 28 Apr 2020 16:39:40 GMT
Content-Length: 687
那么这里如何使用 gzip 包呢?
冉冉说
ABOUTYOU
呼如林
随时随地看视频慕课网APP
相关分类