This is specifically for running webmachine with Unicorn/Rack.
To start off:
bundle
unicorn
You should see "hi" on localhost:8080
This is specifically for running webmachine with Unicorn/Rack.
To start off:
bundle
unicorn
You should see "hi" on localhost:8080
require 'webmachine/adapter' | |
require 'webmachine/adapters/rack' | |
require File.join(File.dirname(__FILE__), 'my_rest_app') | |
run App.adapter |
module MyRESTApp | |
module Resources | |
class Echo < Webmachine::Resource | |
def to_html | |
if @request.query.has_key?("ping") | |
return "<p>PONG</p>" | |
else | |
return "<p>Hi. <a href=\"/?ping=me\">ping me</a></p>" | |
end | |
end | |
end | |
end | |
end |
source 'http://rubygems.org' | |
gem 'webmachine' | |
gem 'unicorn' |
GEM | |
remote: http://rubygems.org/ | |
specs: | |
i18n (0.6.0) | |
kgio (2.6.0) | |
rack (1.4.1) | |
raindrops (0.8.0) | |
unicorn (4.2.0) | |
kgio (~> 2.6) | |
rack | |
raindrops (~> 0.7) | |
webmachine (0.4.2) | |
i18n (>= 0.4.0) | |
PLATFORMS | |
ruby | |
DEPENDENCIES | |
unicorn | |
webmachine |
require 'webmachine' | |
require File.join(File.dirname(__FILE__), 'echo_resource') | |
App = Webmachine::Application.new do |app| | |
app.configure do |config| | |
config.adapter = :Rack | |
end | |
app.routes do | |
add ['*'], MyRESTApp::Resources::Echo | |
end | |
end |