Class: Simple::Httpd::BaseController
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Simple::Httpd::BaseController
show all
- Extended by:
- RouteDescriptions, ServiceAdapter
- Defined in:
- lib/simple/httpd/base_controller/x_processing.rb,
lib/simple/httpd/base_controller.rb,
lib/simple/httpd/base_controller.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/result.rb,
lib/simple/httpd/base_controller/request.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: LoginRequiredError, NotAuthorizedError, NotFoundError
Constant Summary
collapse
{
"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-max-age" => "600",
"access-control-request-headers" => "Content-Type",
"access-control-request-method" => "GET,POST,PATCH,PUT,DELETE,OPTIONS"
}
- H =
::Simple::Httpd::Helpers
Instance Method Summary
collapse
describe_route!, route_descriptions
delete, get, head, mount_service, post, put
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
|
#login_required!(msg) ⇒ Object
93
94
95
|
# File 'lib/simple/httpd/base_controller/error_handling.rb', line 93
def login_required!(msg)
raise LoginRequiredError, msg
end
|
#not_authorized!(msg) ⇒ Object
84
85
86
|
# File 'lib/simple/httpd/base_controller/error_handling.rb', line 84
def not_authorized!(msg)
raise NotAuthorizedError, msg
end
|
#not_found!(msg) ⇒ Object
108
109
110
|
# File 'lib/simple/httpd/base_controller/error_handling.rb', line 108
def not_found!(msg)
raise NotFoundError, msg
end
|
#parsed_body ⇒ Object
2
3
4
5
6
7
8
|
# File 'lib/simple/httpd/base_controller/request.rb', line 2
def parsed_body
return @parsed_body if defined? @parsed_body
@parsed_body = parse_body
rescue RuntimeError => e
raise ArgumentError, e.to_s
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, options)
expect! options => {
status: Integer,
title: String,
description: [String, nil]
}
status options[:status]
options = stringify_hash(options)
options["description"] ||= options["title"]
options["@type"] = error_type(exc)
options["@now"] = Time.now.to_f
json options
end
|