File: custom_middleware.rb

package info (click to toggle)
libinnate-ruby 2010.07-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 812 kB
  • ctags: 621
  • sloc: ruby: 4,242; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 618 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require 'rubygems'
require 'innate'

class Demo
  Innate.node '/'

  def index
    'Hello, World!'
  end

  def empty
    response.status = 405
    ''
  end
end

Innate.start 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

  # Start up the application
  mw.innate
end