Class: Jets::Server::ApiGateway
- Inherits:
-
Object
- Object
- Jets::Server::ApiGateway
- Defined in:
- lib/jets/server/api_gateway.rb
Class Method Summary collapse
- .call(env) ⇒ Object
- .routes_error_message(env) ⇒ Object
-
.routes_table ⇒ Object
Show pretty route table for user to help with debugging in non-production mode.
Class Method Details
.call(env) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/jets/server/api_gateway.rb', line 5 def self.call(env) Jets.boot route = RouteMatcher.new(env).find_route if route proxy = LambdaAwsProxy.new(route, env) triplet = proxy.response else [404, {'Content-Type' => 'text/html'}, [(env)]] end end |
.routes_error_message(env) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/jets/server/api_gateway.rb', line 16 def self.(env) = "<h2>404 Error: Route #{env['PATH_INFO'].sub('/','')} not found</h2>" if Jets.env != "production" << "<p>Here are the routes defined in your application:</p>" << "#{routes_table}" end end |
.routes_table ⇒ Object
Show pretty route table for user to help with debugging in non-production mode
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/jets/server/api_gateway.rb', line 26 def self.routes_table routes = Jets::Router.routes return "Your routes table is empty." if routes.empty? text = "Verb | Path | Controller#action\n" text << "--- | --- | ---\n" routes.each do |route| text << "#{route.method} | #{route.path} | #{route.to}\n" end Kramdown::Document.new(text).to_html end |