Class: Core::Service
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Core::Service
show all
- Includes:
- Endpoint::BasicHandler::EndpointLookup
- Defined in:
- app/api/core/service.rb
Overview
rubocop:todo Style/Documentation
Defined Under Namespace
Modules: Authentication, ContentFiltering, EndpointHandling, ErrorHandling
Classes: DeprecatedAction, Error, MethodNotAllowed, Request, Response, UnsupportedAction
Constant Summary
collapse
- API_VERSION =
1
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command
109
110
111
|
# File 'app/api/core/service.rb', line 109
def command
@command
end
|
Class Method Details
.after_all_actions(&block) ⇒ Object
105
106
107
|
# File 'app/api/core/service.rb', line 105
def self.after_all_actions(&block)
after('/*', &block)
end
|
.api_version_path ⇒ Object
93
94
95
|
# File 'app/api/core/service.rb', line 93
def self.api_version_path
@version = "api/#{API_VERSION}"
end
|
.before_all_actions(&block) ⇒ Object
101
102
103
|
# File 'app/api/core/service.rb', line 101
def self.before_all_actions(&block)
before('/*', &block)
end
|
Instance Method Details
#api_path(*sub_path) ⇒ Object
97
98
99
|
# File 'app/api/core/service.rb', line 97
def api_path(*sub_path)
"#{request.scheme}://#{request.host_with_port}/#{self.class.api_version_path}/#{sub_path.compact.join('/')}"
end
|
#handle_not_found!(_boom) ⇒ Object
This ensures that our Sinatra applications behave properly within the Rails environment. Without this you'll find that only one of the services actually behaves properly, the others will all fail with 404 errors.
66
67
68
69
70
|
# File 'app/api/core/service.rb', line 66
def handle_not_found!(_boom)
@response.status = 404
@response.['X-Cascade'] = 'pass'
@response.body = nil
end
|
#redirect_to(url, body) ⇒ Object
82
83
84
85
86
|
# File 'app/api/core/service.rb', line 82
def redirect_to(url, body)
status(301) ('Location' => url)
body(body)
end
|
#redirect_to_multiple_locations(body) ⇒ Object
88
89
90
91
|
# File 'app/api/core/service.rb', line 88
def redirect_to_multiple_locations(body)
status(300) body(body)
end
|