Class: Capsium::Reactor::ContentApi
- Inherits:
-
Object
- Object
- Capsium::Reactor::ContentApi
- Includes:
- Responses
- Defined in:
- lib/capsium/reactor/content_api.rb,
sig/capsium/reactor/content_api.rbs
Overview
Content writes over the mount's overlay (ARCHITECTURE.md section 5a): PUT creates/overwrites a content file, DELETE records a tombstone. Text bodies only for v1.
Constant Summary collapse
- WRITE_METHODS =
%w[PUT DELETE].freeze
- CONTENT_PREFIX =
"#{Package::CONTENT_DIR}/".freeze
Class Method Summary collapse
Instance Method Summary collapse
- #handle(inner_path, request, response) ⇒ Object
-
#initialize(mount) ⇒ ContentApi
constructor
A new instance of ContentApi.
Methods included from Responses
#respond_error, #respond_forbidden, #respond_json, #respond_method_not_allowed, #respond_not_found, #respond_not_implemented, #respond_text
Constructor Details
#initialize(mount) ⇒ ContentApi
Returns a new instance of ContentApi.
22 23 24 |
# File 'lib/capsium/reactor/content_api.rb', line 22 def initialize(mount) @mount = mount end |
Class Method Details
.write_method?(method) ⇒ Boolean
18 19 20 |
# File 'lib/capsium/reactor/content_api.rb', line 18 def self.write_method?(method) WRITE_METHODS.include?(method) end |
Instance Method Details
#handle(inner_path, request, response) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/capsium/reactor/content_api.rb', line 26 def handle(inner_path, request, response) return read_only(response) unless @mount.writable? route = @mount.routes.resolve(inner_path) return guard_route(route, inner_path, response) if route && !writable_route?(route) case request.request_method when "PUT" then put_content(inner_path, route, request, response) when "DELETE" then delete_content(inner_path, route, response) else respond_method_not_allowed(response) end end |