Class: Rubee::Application
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize ⇒ Application
constructor
A new instance of Application.
- #middlewares ⇒ Object
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
36 37 38 |
# File 'lib/rubee.rb', line 36 def initialize Autoload.call end |
Instance Method Details
#call(env) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/rubee.rb', line 40 def call(env) # init rack request request = Rack::Request.new(env) # Add default path for assets register_assets_routes # define route route = Router.route_for(request) # if react is the view so we would like to delegate not cauth by rubee routes to it. if Rubee::Configuration.react[:on] && !route index = File.read(File.join(Rubee::APP_ROOT, Rubee::LIB, 'app/views', 'index.html')) return [200, { 'content-type' => 'text/html' }, [index]] end # if not found return 404 return [404, { 'content-type' => 'text/plain' }, ['Route not found']] unless route # init controller class controller_class = if route[:namespace] "#{route[:namespace].to_s.camelize}::#{route[:controller].camelize}Controller" else "#{route[:controller].camelize}Controller" end # instantiate controller controller = Object.const_get(controller_class).new(request, route) # get the action action = route[:action] # fire the action controller.send(action) end |
#middlewares ⇒ Object
68 69 70 |
# File 'lib/rubee.rb', line 68 def middlewares Rubee::Configuration.middlewares end |