Class: Simple::Httpd::BaseController
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Simple::Httpd::BaseController
- Defined in:
- lib/simple/httpd/base_controller/x_processing.rb,
lib/simple/httpd/base_controller.rb,
lib/simple/httpd/base_controller/erb.rb,
lib/simple/httpd/base_controller/cors.rb,
lib/simple/httpd/base_controller/json.rb,
lib/simple/httpd/base_controller/debug.rb,
lib/simple/httpd/base_controller/build_url.rb,
lib/simple/httpd/base_controller/error_handling.rb
Overview
Simple::SQL connection handling
Defined Under Namespace
Classes: NotFoundError
Constant Summary collapse
- CORS_HEADERS =
{ "access-control-allow-credentials" => "true", "access-control-allow-headers" => "Origin,X-Requested-With,Content-Type,Accept,Session-Id", "access-control-allow-methods" => "*", "access-control-allow-origin" => "*", # "access-control-expose-headers" => "X-Total-Entries,X-Total-Pages,X-Page,X-Per-Page", # "access-control-max-age" => "-1", "access-control-max-age" => "600", "access-control-request-headers" => "Content-Type", "access-control-request-method" => "GET,POST,PATCH,PUT,DELETE,OPTIONS" }
Instance Method Summary collapse
Instance Method Details
#json(result) ⇒ Object
2 3 4 5 |
# File 'lib/simple/httpd/base_controller/json.rb', line 2 def json(result) content_type :json generate_json(result) end |
#parsed_json_body ⇒ Object
32 33 34 |
# File 'lib/simple/httpd/base_controller/json.rb', line 32 def parsed_json_body @parsed_json_body ||= parse_json_body end |
#render_error(exc, options) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/simple/httpd/base_controller/error_handling.rb', line 23 def render_error(exc, ) expect! => { status: Integer, title: String, description: [String, nil] } status [:status] = stringify_hash() ["description"] ||= ["title"] ["@type"] = error_type(exc) ["@now"] = Time.now.to_f json end |