Class: Core::Service
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Core::Service
show all
- Includes:
- Endpoint::BasicHandler::EndpointLookup
- Defined in:
- app/api/core/service.rb
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.
110
111
112
|
# File 'app/api/core/service.rb', line 110
def command
@command
end
|
Class Method Details
.after_all_actions ⇒ Object
106
107
108
|
# File 'app/api/core/service.rb', line 106
def self.after_all_actions(&)
after('/*', &)
end
|
.api_version_path ⇒ Object
94
95
96
|
# File 'app/api/core/service.rb', line 94
def self.api_version_path
@version = "api/#{API_VERSION}"
end
|
.before_all_actions ⇒ Object
102
103
104
|
# File 'app/api/core/service.rb', line 102
def self.before_all_actions(&)
before('/*', &)
end
|
Instance Method Details
#api_path(*sub_path) ⇒ Object
98
99
100
|
# File 'app/api/core/service.rb', line 98
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.
67
68
69
70
71
|
# File 'app/api/core/service.rb', line 67
def handle_not_found!(_boom)
@response.status = 404
@response.['X-Cascade'] = 'pass'
@response.body = nil
end
|
#redirect_to(url, body) ⇒ Object
83
84
85
86
87
|
# File 'app/api/core/service.rb', line 83
def redirect_to(url, body)
status(301) ('Location' => url)
body(body)
end
|
#redirect_to_multiple_locations(body) ⇒ Object
89
90
91
92
|
# File 'app/api/core/service.rb', line 89
def redirect_to_multiple_locations(body)
status(300) body(body)
end
|