Sha256: dee645672df58e309e05aa68361d85a534d4c151181bcff82bd8135b13a720f7
Contents?: true
Size: 969 Bytes
Versions: 1
Compression:
Stored size: 969 Bytes
Contents
require 'reel' require 'octarine' module Reel # Define Reel endpoints using a sinatra-like dsl (provided by octarine) module App def self.included(base) base.class_eval do include Octarine::App attr_accessor :server end end def initialize(host, port) super() @server = Reel::Server.supervise(host, port) do |connection| while request = connection.request status, headers, body = call Rack::MockRequest.env_for(request.url, :method => request.method, :input => request.body) response_klass = body.is_a?(Stream) ? StreamResponse : Response connection.respond(response_klass.new(status_symbol(status), headers, body)) end end end def status_symbol(status) status.is_a?(Fixnum) ? Http::Response::STATUS_CODES[status].downcase.gsub(/\s|-/, '_').to_sym : status.to_sym end def terminate @server.terminate if @server end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
reel-0.4.0.pre | lib/reel/app.rb |