module Clayoven::Httpd
The entry point for clayoven httpd
Run a simple webrick http server to test on localhost:8000
Public Class Methods
start()
click to toggle source
Start the server, and shut it down on :INT
# File lib/clayoven/httpd.rb, line 10 def self.start port = 8000 callback = proc do |req, res| # A couple of URL rewriting rules; simple stuff if %r{^/$} =~ req.path_info res.set_redirect WEBrick::HTTPStatus::Found, "index.html" elsif /^(?<uri>[^.]+)$/ =~ req.path_info res.set_redirect WEBrick::HTTPStatus::Found, "#{URI.parse(uri)}.html" end end server = WEBrick::HTTPServer.new( Port: port, RequestCallback: callback, DocumentRoot: Dir.pwd ) puts "[#{"HTTP".green}]: Serving at: http://localhost:#{port}" trap(:INT) { server.shutdown } server.start end