landline/test_combined.rb

27 lines
861 B
Ruby

require 'webrick'
require_relative 'hyde'
server = WEBrick::HTTPServer.new :Port => 8000
trap 'INT' do server.shutdown end
server.mount_proc '/' do |req,res|
Hyde::Pathspec.new '/' do
serve "index.html" do |ctx|
ctx.response.body = "This is a test of webrick+hyde combination
If you're seeing this, this means it's a success"
ctx.response["Content-Type"] = "text/plain"
end
path "about" do
serve "webrick" do |ctx|
ctx.response.body = "WEBrick is weird and pretty undocumented"
ctx.response["Content-Type"] = "text/plain"
end
serve "hyde" do |ctx|
ctx.response.body = "Hyde was born because i thought Sinatra is cool, but nested paths are even cooler"
ctx.response["Content-Type"] = "text/plain"
end
end
end.match(Hyde::Context.new(req.path, req, res))
end
server.start