Module: Webmachine
- Extended by:
- Translation
- Defined in:
- lib/webmachine.rb,
lib/webmachine/etags.rb,
lib/webmachine/trace.rb,
lib/webmachine/cookie.rb,
lib/webmachine/errors.rb,
lib/webmachine/adapter.rb,
lib/webmachine/headers.rb,
lib/webmachine/request.rb,
lib/webmachine/version.rb,
lib/webmachine/adapters.rb,
lib/webmachine/decision.rb,
lib/webmachine/resource.rb,
lib/webmachine/response.rb,
lib/webmachine/streaming.rb,
lib/webmachine/trace/fsm.rb,
lib/webmachine/dispatcher.rb,
lib/webmachine/media_type.rb,
lib/webmachine/application.rb,
lib/webmachine/translation.rb,
lib/webmachine/chunked_body.rb,
lib/webmachine/decision/fsm.rb,
lib/webmachine/adapters/rack.rb,
lib/webmachine/adapters/reel.rb,
lib/webmachine/configuration.rb,
lib/webmachine/decision/flow.rb,
lib/webmachine/quoted_string.rb,
lib/webmachine/decision/conneg.rb,
lib/webmachine/decision/falsey.rb,
lib/webmachine/adapters/mongrel.rb,
lib/webmachine/adapters/webrick.rb,
lib/webmachine/decision/helpers.rb,
lib/webmachine/dispatcher/route.rb,
lib/webmachine/resource/tracing.rb,
lib/webmachine/adapters/hatetepe.rb,
lib/webmachine/streaming/encoder.rb,
lib/webmachine/resource/callbacks.rb,
lib/webmachine/resource/encodings.rb,
lib/webmachine/resource/entity_tags.rb,
lib/webmachine/streaming/io_encoder.rb,
lib/webmachine/trace/resource_proxy.rb,
lib/webmachine/trace/trace_resource.rb,
lib/webmachine/resource/authentication.rb,
lib/webmachine/streaming/fiber_encoder.rb,
lib/webmachine/trace/pstore_trace_store.rb,
lib/webmachine/adapters/lazy_request_body.rb,
lib/webmachine/streaming/callable_encoder.rb,
lib/webmachine/streaming/enumerable_encoder.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: Adapters, Decision, QuotedString, Streaming, Trace, Translation Classes: Adapter, Application, ChunkedBody, Configuration, Cookie, Dispatcher, ETag, Error, Headers, InvalidResource, MalformedRequest, MediaType, Request, Resource, Response, WeakETag
Constant Summary collapse
- VERSION =
Library version
"1.1.0"
- SERVER_STRING =
String for use in “Server” HTTP response header, which includes the VERSION.
"Webmachine-Ruby/#{VERSION}"
Class Method Summary collapse
-
.application ⇒ Application
The default global Application.
-
.configuration ⇒ Configuration
The current configuration.
-
.configuration=(configuration) ⇒ Object
Sets the current configuration.
-
.configure {|config| ... } ⇒ Object
Yields the current configuration to the passed block.
-
.render_error(code, req, res, options = {}) ⇒ Object
Renders a standard error message body for the response.
-
.routes(&block) ⇒ Webmachine
Evaluates the passed block in the context of Dispatcher for use in adding a number of routes at once.
-
.run ⇒ Object
Starts Webmachine’s default global Application serving requests.
Methods included from Translation
Class Method Details
.application ⇒ Application
Returns the default global Application.
105 106 107 |
# File 'lib/webmachine/application.rb', line 105 def self.application @application ||= Application.new end |
.configuration ⇒ Configuration
Returns the current configuration.
30 31 32 |
# File 'lib/webmachine/configuration.rb', line 30 def self.configuration application.configuration end |
.configuration=(configuration) ⇒ Object
Sets the current configuration
37 38 39 |
# File 'lib/webmachine/configuration.rb', line 37 def self.configuration=(configuration) application.configuration = configuration end |
.configure {|config| ... } ⇒ Object
Yields the current configuration to the passed block.
23 24 25 26 |
# File 'lib/webmachine/configuration.rb', line 23 def self.configure(&block) application.configure(&block) self end |
.render_error(code, req, res, options = {}) ⇒ Object
Renders a standard error message body for the response. The standard messages are defined in localization files.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/webmachine/errors.rb', line 14 def self.render_error(code, req, res, ={}) res.code = code unless res.body title, = t(["errors.#{code}.title", "errors.#{code}.message"], { :method => req.method, :error => res.error}.merge()) res.body = t("errors.standard_body", {:title => title, :message => , :version => Webmachine::SERVER_STRING}.merge()) res.headers['Content-Type'] = "text/html" end end |
.routes(&block) ⇒ Webmachine
Evaluates the passed block in the context of Dispatcher for use in adding a number of routes at once.
86 87 88 89 |
# File 'lib/webmachine/dispatcher.rb', line 86 def self.routes(&block) application.routes(&block) self end |
.run ⇒ Object
Starts Webmachine’s default global Application serving requests
22 23 24 |
# File 'lib/webmachine.rb', line 22 def self.run application.run end |