Module: Webmachine

Extended by:
Translation
Defined in:
lib/webmachine.rb,
lib/webmachine/errors.rb,
lib/webmachine/request.rb,
lib/webmachine/webrick.rb,
lib/webmachine/headers.rb,
lib/webmachine/version.rb,
lib/webmachine/response.rb,
lib/webmachine/resource.rb,
lib/webmachine/dispatcher.rb,
lib/webmachine/translation.rb,
lib/webmachine/decision/fsm.rb,
lib/webmachine/decision/flow.rb,
lib/webmachine/decision/conneg.rb,
lib/webmachine/decision/helpers.rb,
lib/webmachine/dispatcher/route.rb,
lib/webmachine/resource/callbacks.rb,
lib/webmachine/resource/encodings.rb

Overview

Webmachine is a toolkit for making well-behaved HTTP applications. It is based on the Erlang library of the same name.

Defined Under Namespace

Modules: Decision, Dispatcher, Translation, WEBrick Classes: Headers, Request, Resource, Response

Constant Summary

VERSION =
"0.1.0"
SERVER_STRING =
"Webmachine.rb/#{VERSION}"

Class Method Summary collapse

Methods included from Translation

t

Class Method Details

.render_error(code, req, res) ⇒ Object

Renders a standard error message body for the response. The standard messages are defined in localization files.



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/webmachine/errors.rb', line 12

def self.render_error(code, req, res)
  unless res.body
    title, message = t(["errors.#{code}.title", "errors.#{code}.message"],
                       :method => req.method,
                       :error => res.error)
    res.body = t("errors.standard_body",
                 :title => title,
                 :message => message,
                 :version => Webmachine::SERVER_STRING)
    res.headers['Content-Type'] = "text/html"
  end
end