Class: Landline::App
- Inherits:
-
Object
- Object
- Landline::App
- Extended by:
- DSL::CommonMethods, DSL::PathConstructors, DSL::PathMethods, DSL::ProbeConstructors, DSL::ProbeMethods
- Defined in:
- lib/landline/app.rb
Overview
Rack application interface
Class Attribute Summary collapse
-
.middleware ⇒ Object
Returns the value of attribute middleware.
-
.setup_chain ⇒ Object
Returns the value of attribute setup_chain.
Class Method Summary collapse
-
.inherited(subclass) ⇒ Object
Duplicate used middleware for the subclassed app.
-
.method_missing(symbol, *args, **params, &callback) ⇒ Object
Store applied app manipulations.
-
.respond_to_missing?(symbol, _include_private) ⇒ Boolean
Check if Server can respond to given symbol.
-
.use(middleware) ⇒ Object
Include a middleware in application.
Instance Method Summary collapse
-
#call(env) ⇒ Array(Integer,Hash,Array)
Rack ingress point.
-
#initialize(*args, **opts) ⇒ App
constructor
A new instance of App.
Methods included from DSL::CommonMethods
Methods included from DSL::ProbeMethods
cookie, defer, delete_cookie, delete_header, escape_html, file, form, form?, header, hijack, json, json?, jump, partial_hijack, query, query?, query_shallow, redirect, redirect_with_method, request, session, status, unescape_html
Methods included from DSL::ProbeConstructors
Methods included from DSL::PathConstructors
connect, delete, get, head, link, options, patch, path, post, probe, put, register, serve, trace, websocket
Methods included from DSL::PathMethods
bounce, filter, handle, index, nobounce, pipeline, plugin, postprocess, preprocess, remap, root
Constructor Details
#initialize(*args, **opts) ⇒ App
Returns a new instance of App.
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/landline/app.rb', line 46 def initialize(*args, **opts) setup_chain = self.class.setup_chain @app = ::Landline::Server.new(*args, **opts) do setup_chain.each do |symbol, cargs, cparams, callback| send(symbol, *cargs, **cparams, &callback) end end self.class.middleware&.reverse_each do |cls| @app = cls.new(@app) end end |
Class Attribute Details
.middleware ⇒ Object
Returns the value of attribute middleware.
43 44 45 |
# File 'lib/landline/app.rb', line 43 def middleware @middleware end |
.setup_chain ⇒ Object
Returns the value of attribute setup_chain.
43 44 45 |
# File 'lib/landline/app.rb', line 43 def setup_chain @setup_chain end |
Class Method Details
.inherited(subclass) ⇒ Object
Duplicate used middleware for the subclassed app
15 16 17 18 19 20 |
# File 'lib/landline/app.rb', line 15 def inherited(subclass) super(subclass) @setup_chain ||= [] subclass.middleware = @middleware.dup subclass.setup_chain = @setup_chain.dup end |
.method_missing(symbol, *args, **params, &callback) ⇒ Object
Store applied app manipulations
35 36 37 38 39 40 41 |
# File 'lib/landline/app.rb', line 35 def method_missing(symbol, *args, **params, &callback) if Landline::ServerContext.instance_methods.include? symbol @setup_chain.append([symbol, args, params, callback]) else super(symbol, *args, **params, &callback) end end |
.respond_to_missing?(symbol, _include_private) ⇒ Boolean
Check if Server can respond to given symbol
30 31 32 |
# File 'lib/landline/app.rb', line 30 def respond_to_missing?(symbol, _include_private) Landline::ServerContext.instance_methods.include?(symbol) || super end |
.use(middleware) ⇒ Object
Include a middleware in application
24 25 26 27 |
# File 'lib/landline/app.rb', line 24 def use(middleware) @middleware ||= [] @middleware.append(middleware) end |
Instance Method Details
#call(env) ⇒ Array(Integer,Hash,Array)
Rack ingress point.
61 62 63 |
# File 'lib/landline/app.rb', line 61 def call(env) @app.call(env) end |