Sha256: 0bd8e3126313218cab8dba7d86fe60d73018aa2634fcd8f60d04cd6a4dea18b6

Contents?: true

Size: 1001 Bytes

Versions: 2

Compression:

Stored size: 1001 Bytes

Contents

require 'innate'

class Demo
  include Innate::Node
  map '/'

  def index
    'Hello, World!'
  end

  def empty
    response.status = 405
    ''
  end
end

# Make sure you do this before Innate.start, otherwise you have to use
# Innate.middleware! to force a rebuild in the MiddlewareCompiler.
Innate.middleware :innate do |mw|
  # Makes sure all requests and responses conform to Rack protocol
  mw.use Rack::Lint

  # Avoid showing empty failure pages, give information when it happens.
  mw.use Rack::ShowStatus

  # Catch exceptions inside Innate and give nice status info
  mw.use Rack::ShowExceptions

  # Log access
  mw.use Rack::CommonLogger

  # Reload modified files before request
  mw.use Rack::Reloader

  # Initializes the Current objects: Request, Response, and Session
  mw.use Innate::Current

  # This will try to find a static file in /public first, and try DynaMap if
  # Rack::File returns a 404 status.
  mw.cascade Rack::File.new('public'), Innate::DynaMap
end

Innate.start

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
manveru-innate-2009.02.06 example/custom_middleware.rb
manveru-innate-2009.02.21 example/custom_middleware.rb