diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-09 13:19:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-09 13:19:22 +0000 |
commit | c21c3b0befeb46a51b6bf3758ffa30813bea0ff0 (patch) | |
tree | 9754ff1ca740f6346cf8483ec915d4054bc5da2d /web/server/h2o/libh2o/examples/h2o_mruby/hello.rb | |
parent | Adding upstream version 1.43.2. (diff) | |
download | netdata-c21c3b0befeb46a51b6bf3758ffa30813bea0ff0.tar.xz netdata-c21c3b0befeb46a51b6bf3758ffa30813bea0ff0.zip |
Adding upstream version 1.44.3.upstream/1.44.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | web/server/h2o/libh2o/examples/h2o_mruby/hello.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/web/server/h2o/libh2o/examples/h2o_mruby/hello.rb b/web/server/h2o/libh2o/examples/h2o_mruby/hello.rb new file mode 100644 index 000000000..bceb7b0cd --- /dev/null +++ b/web/server/h2o/libh2o/examples/h2o_mruby/hello.rb @@ -0,0 +1,32 @@ +# paths: +# /: +# file.dir: examples/doc_root +# mruby.handler-file: /path/to/hello.rb + +class HelloApp + def call(env) + h = "hello" + m = "from h2o_mruby" + + ua = env["HTTP_USER_AGENT"] + new_ua = "new-#{ua}-h2o_mruby" + path = env["PATH_INFO"] + host = env["HTTP_HOST"] + method = env["REQUEST_METHOD"] + query = env["QUERY_STRING"] + input = env["rack.input"] ? env["rack.input"].read : "" + + msg = "#{h} #{m}. User-Agent:#{ua} New User-Agent:#{new_ua} path:#{path} host:#{host} method:#{method} query:#{query} input:#{input}" + + [200, + { + "content-type" => "text/plain; charset=utf-8", + "user-agent" => new_ua, + }, + ["#{msg}\n"] + ] + + end +end + +HelloApp.new |