{"id":2115,"date":"2015-02-24T17:39:50","date_gmt":"2015-02-24T17:39:50","guid":{"rendered":"http:\/\/41j.com\/blog\/?p=2115"},"modified":"2015-02-23T17:44:22","modified_gmt":"2015-02-23T17:44:22","slug":"serving-gziped-connect-via-http-golang","status":"publish","type":"post","link":"https:\/\/41j.com\/blog\/2015\/02\/serving-gziped-connect-via-http-golang\/","title":{"rendered":"Serving gziped connect via HTTP in golang"},"content":{"rendered":"<p>The builtin HTTP server in the golang standard library does not serve gziped content. However you can relatively easily add a wrapper function to compress data on the fly. The best tool to do this appears to be go.httpgzip. A basic example of its usage might look like this:<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\nimport (\r\n  &quot;github.com\/daaku\/go.httpgzip&quot;\r\n  &quot;net\/http&quot;\r\n)\r\n\r\nfunc main() {\r\n  http.Handle(&quot;\/&quot;, httpgzip.NewHandler(http.FileServer(http.Dir(&quot;.&quot;))))\r\n  err := http.ListenAndServe(&quot;:80&quot;, nil)\r\n  if err != nil {\r\n    panic(&quot;Error: &quot; + err.Error())\r\n  }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The builtin HTTP server in the golang standard library does not serve gziped content. However you can relatively easily add a wrapper function to compress data on the fly. The best tool to do this appears to be go.httpgzip. A basic example of its usage might look like this: import ( &quot;github.com\/daaku\/go.httpgzip&quot; &quot;net\/http&quot; ) func [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-2115","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1RRoU-y7","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts\/2115","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/comments?post=2115"}],"version-history":[{"count":1,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts\/2115\/revisions"}],"predecessor-version":[{"id":2116,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts\/2115\/revisions\/2116"}],"wp:attachment":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/media?parent=2115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/categories?post=2115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/tags?post=2115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}