Module: Webmachine
- Extended by:
- HeaderNegotiation, Translation
- Defined in:
- lib/webmachine.rb,
lib/webmachine/etags.rb,
lib/webmachine/trace.rb,
lib/webmachine/cookie.rb,
lib/webmachine/errors.rb,
lib/webmachine/events.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/constants.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/trace/listener.rb,
lib/webmachine/decision/conneg.rb,
lib/webmachine/decision/falsey.rb,
lib/webmachine/adapters/httpkit.rb,
lib/webmachine/adapters/webrick.rb,
lib/webmachine/decision/helpers.rb,
lib/webmachine/dispatcher/route.rb,
lib/webmachine/resource/tracing.rb,
lib/webmachine/streaming/encoder.rb,
lib/webmachine/header_negotiation.rb,
lib/webmachine/resource/callbacks.rb,
lib/webmachine/resource/encodings.rb,
lib/webmachine/adapters/rack_mapped.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/events/instrumented_event.rb,
lib/webmachine/streaming/callable_encoder.rb,
lib/webmachine/streaming/enumerable_encoder.rb
Overview
String for use in “Server” HTTP response header, which includes the VERSION.
Defined Under Namespace
Modules: Adapters, Decision, Events, HeaderNegotiation, QuotedString, RescuableException, Streaming, Trace, Translation Classes: Adapter, Application, ChunkedBody, Configuration, Cookie, Dispatcher, ETag, Error, Headers, InvalidResource, MalformedRequest, MediaType, Request, Resource, Response, WeakETag
Constant Summary collapse
- VERSION =
"1.5.0".freeze
- SERVER_STRING =
"Webmachine-Ruby/#{VERSION}".freeze
- CRLF =
"\r\n".freeze
- CONTENT_TYPE =
'Content-Type'.freeze
- TEXT_HTML =
'text/html'.freeze
- DATE =
'Date'.freeze
- TRANSFER_ENCODING =
'Transfer-Encoding'.freeze
- CONTENT_LENGTH =
'Content-Length'.freeze
- UNDERSCORE =
'_'.freeze
- DASH =
'-'.freeze
- SLASH =
'/'.freeze
- MATCHES_ALL =
'*/*'.freeze
- GET_METHOD =
"GET"
- HEAD_METHOD =
"HEAD"
- POST_METHOD =
"POST"
- PUT_METHOD =
"PUT"
- DELETE_METHOD =
"DELETE"
- OPTIONS_METHOD =
"OPTIONS"
- TRACE_METHOD =
"TRACE"
- CONNECT_METHOD =
"CONNECT"
- STANDARD_HTTP_METHODS =
[ GET_METHOD, HEAD_METHOD, POST_METHOD, PUT_METHOD, DELETE_METHOD, TRACE_METHOD, CONNECT_METHOD, OPTIONS_METHOD ].map!(&:freeze)
- COLON =
':'.freeze
- HTTP =
'http'.freeze
- HOST =
'Host'.freeze
- CONTENT_ENCODING =
'Content-Encoding'.freeze
- CHARSET =
'Charset'.freeze
- SPLIT_SEMI =
/\s*,\s*/.freeze
- STAR =
'*'.freeze
- LOCATION =
'Location'.freeze
- IDENTITY =
'identity'.freeze
- SERVER =
'Server'.freeze
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 HeaderNegotiation
ensure_content_length, ensure_date_header
Methods included from Translation
Class Method Details
.application ⇒ Application
Returns the default global Application.
106 107 108 |
# File 'lib/webmachine/application.rb', line 106 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.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/webmachine/errors.rb', line 17 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 ensure_content_length(res) ensure_date_header(res) end |
.routes(&block) ⇒ Webmachine
Evaluates the passed block in the context of Dispatcher for use in adding a number of routes at once.
94 95 96 97 |
# File 'lib/webmachine/dispatcher.rb', line 94 def self.routes(&block) application.routes(&block) self end |
.run ⇒ Object
Starts Webmachine’s default global Application serving requests
24 25 26 |
# File 'lib/webmachine.rb', line 24 def self.run application.run end |