class Capsium::Reactor::DataApi
REST CRUD over a mount’s datasets (ARCHITECTURE.md sections 5 and 5a): JSON item append/read/replace/delete against the overlay- merged collection. Writes go only to the mount’s writable overlay; the immutable package never changes on disk.
Constants
- COLLECTION_PATTERN
- ITEM_PATTERN
- PREFIX
Public Class Methods
(Mount mount) → void
Source
# File lib/capsium/reactor/data_api.rb, line 22 def initialize(mount) @mount = mount end
(String inner_path) → bool
Source
# File lib/capsium/reactor/data_api.rb, line 18 def self.path?(inner_path) inner_path.start_with?(PREFIX) end
Public Instance Methods
(String inner_path, untyped request, untyped response) → untyped
Source
# File lib/capsium/reactor/data_api.rb, line 37 def handle(inner_path, request, response) route = route_for(inner_path) return respond_not_found(response) unless route dataset = @mount.package.storage.dataset(route.dataset) return respond_not_found(response) unless dataset collection = COLLECTION_PATTERN.match(inner_path) if collection handle_collection(dataset, request, response) else handle_item(dataset, ITEM_PATTERN.match(inner_path)[:id], request, response) end end
(String inner_path) → Package::Route?
Source
# File lib/capsium/reactor/data_api.rb, line 29 def route_for(inner_path) match = COLLECTION_PATTERN.match(inner_path) || ITEM_PATTERN.match(inner_path) return nil unless match route = @mount.routes.resolve("#{PREFIX}#{match[:dataset]}") route if route&.dataset == match[:dataset] end
The declared dataset route a data path addresses (the collection route, also for item paths), or nil when the package does not route this dataset — undeclared datasets are not served.