diff --git a/rack-async-http-falcon-gzip/Gemfile b/rack-async-http-falcon-gzip/Gemfile new file mode 100644 index 0000000..278a074 --- /dev/null +++ b/rack-async-http-falcon-gzip/Gemfile @@ -0,0 +1,5 @@ +source "https://rubygems.org" + +gem "rack" +gem "falcon" +gem "async-http" diff --git a/rack-async-http-falcon-gzip/Gemfile.lock b/rack-async-http-falcon-gzip/Gemfile.lock new file mode 100644 index 0000000..61fc715 --- /dev/null +++ b/rack-async-http-falcon-gzip/Gemfile.lock @@ -0,0 +1,68 @@ +GEM + remote: https://rubygems.org/ + specs: + async (1.29.0) + console (~> 1.10) + nio4r (~> 2.3) + timers (~> 4.1) + async-container (0.16.8) + async (~> 1.0) + async-io (~> 1.26) + async-http (0.56.1) + async (~> 1.25) + async-io (~> 1.28) + async-pool (~> 0.2) + protocol-http (~> 0.22.0) + protocol-http1 (~> 0.14.0) + protocol-http2 (~> 0.14.0) + async-http-cache (0.4.0) + async-http (~> 0.56) + async-io (1.30.2) + async (~> 1.14) + async-pool (0.3.5) + async (~> 1.25) + build-environment (1.13.0) + console (1.11.1) + fiber-local + falcon (0.38.0) + async (~> 1.13) + async-container (~> 0.16.0) + async-http (~> 0.56.0) + async-http-cache (~> 0.4.0) + async-io (~> 1.22) + build-environment (~> 1.13) + bundler + localhost (~> 1.1) + process-metrics (~> 0.2.0) + rack (>= 1.0) + samovar (~> 2.1) + fiber-local (1.0.0) + localhost (1.1.7) + mapping (1.1.1) + nio4r (2.5.7) + process-metrics (0.2.1) + console (~> 1.8) + samovar (~> 2.1) + protocol-hpack (1.4.2) + protocol-http (0.22.0) + protocol-http1 (0.14.0) + protocol-http (~> 0.22) + protocol-http2 (0.14.2) + protocol-hpack (~> 1.4) + protocol-http (~> 0.18) + rack (2.2.3) + samovar (2.1.4) + console (~> 1.0) + mapping (~> 1.0) + timers (4.3.3) + +PLATFORMS + ruby + +DEPENDENCIES + async-http + falcon + rack + +BUNDLED WITH + 2.1.4 diff --git a/rack-async-http-falcon-gzip/README.md b/rack-async-http-falcon-gzip/README.md new file mode 100644 index 0000000..a1e26b5 --- /dev/null +++ b/rack-async-http-falcon-gzip/README.md @@ -0,0 +1,11 @@ +Example app using: + * rack + * falcon + * async-http + +Notes: + * Demo how to use `Accept-Encoding: gzip` + + Running: + + falcon serve --count 1 diff --git a/rack-async-http-falcon-gzip/app.rb b/rack-async-http-falcon-gzip/app.rb new file mode 100644 index 0000000..a416672 --- /dev/null +++ b/rack-async-http-falcon-gzip/app.rb @@ -0,0 +1,26 @@ +require "async" +require "async/http/internet" + +class App + def self.call(env) + internet = Async::HTTP::Internet.new + url = "http://httpbin.org/gzip" + + # headers can be a hash... + headers = { + "accept-encoding" => "gzip", + "user-agent" => "example", + } + + # ...or an array... + headers = [ + ["accept-encoding", "gzip"], + ["user-agent", "example"], + ] + + response = internet.get(url, headers) + body = JSON.parse(response.read) + + [200, {}, [body.to_json]] + end +end diff --git a/rack-async-http-falcon-gzip/config.ru b/rack-async-http-falcon-gzip/config.ru new file mode 100644 index 0000000..b929d04 --- /dev/null +++ b/rack-async-http-falcon-gzip/config.ru @@ -0,0 +1,7 @@ +require "rubygems" +require "bundler" +Bundler.require + +require_relative "app" + +run App