Skip to content

Commit

Permalink
Adds a transparent gzip compression example using ZLibCompressor.
Browse files Browse the repository at this point in the history
  • Loading branch information
arteymix committed May 27, 2015
1 parent b8a79c5 commit 5ec8e3d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions examples/app/app.vala
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ app.get ("", (req, res) => {
res.end ();
});

// default route
app.get ("gzip", (req, res) => {
var template = new View.from_stream (resources_open_stream ("/templates/home.html", ResourceLookupFlags.NONE));

res.headers.append ("Content-Encoding", "gzip");
res.body = new ConverterOutputStream (res.body, new ZlibCompressor (ZlibCompressorFormat.GZIP));

template.stream (res.body);
res.end ();
});

app.get ("query", (req, res) => {
var writer = new DataOutputStream (res.body);

Expand Down
1 change: 1 addition & 0 deletions examples/app/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ <h4>Basics</h4>
<li><a href="/asdasd">not found</a></li>
<li><a href="/not-found">not found (thrown)</a></li>
<li><a href="/urlencoded-data/">parse url-encoded data</a></li>
<li><a href="/gzip">gzip compression</a></li>
</ul>
<h4>Router features</h4>
<ul class="list-inline">
Expand Down

0 comments on commit 5ec8e3d

Please sign in to comment.