Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
a tiny web framework built on top of eventmachine_httpserver (abandoned)
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
app/controllers
config
lib/em
spec
.gitignore
.rspec
Gemfile
Gemfile.lock
README.md
main.rb

README.md

em-micro

em-micro is an unfinished micro web framework that is built on top of eventmachine_httpserver. Feel free to do whatever you like with it. Requires Ruby 1.9.2+.

EXAMPLE APP

class MyApp < EM::Micro::App
end

class HelloController < EM::Micro::Controller::Base
  def index
    response.content = "<h1>Hello #{params['name'] || 'World'}!</h1>"
    response.send_response
  end
end

MyApp.define_routes do
  get '/', HelloController, :index
end

EM.run do
  host = '0.0.0.0'
  port = ENV['PORT'] || 3000
  MyApp.start host, port
  puts "MyApp running at http://#{host}:#{port}"
end

EXAMPLE SPEC

describe 'routing' do
  subject { MyApp }

  it { should route(:get => '/').to(HelloController, :index) }
end

describe HelloController, :type => :controller do
  describe 'GET index' do
    context 'when no name is given' do
      it 'says Hello World!' do
        get :index
        response.status.should == 200
        response.content_type.should == 'text/html'
        response.content.should == '<h1>Hello World!</h1>'
      end
    end

    context 'when name is given' do
      it 'says Hello <name>!' do
        get :index, :name => 'Pete'
        response.status.should == 200
        response.content_type.should == 'text/html'
        response.content.should == '<h1>Hello Pete!</h1>'
      end
    end
  end
end

LICENSE

Copyright (c) 2011 Peter Jihoon Kim. This software is licensed under the MIT License.

Something went wrong with that request. Please try again.