class Capsium::Package::Route
A single route entry (ARCHITECTURE.md section 4). Kinds are discriminated by key, MECE:
-
{path, resource, headers?, visibility?} – static file
-
{path, dataset, accessControl?} – dataset route
-
{path, method, handler, …} – dynamic handler (parsed, accepted-and-ignored; reactors respond 501)
Route inheritance (05x-routing): a resource of the form “<dependency-guid>/<path>” (a URI, i.e. containing “://”) pulls content from a dependency package; “remap” replaces the serving path; “responseRewrite”/“responseHeaders” post-process the response; “requestHeaders” are recorded for forwarding reactors (the Ruby reactor serves statically and does not forward, so they do not alter its responses).
Constants
- DATASET_PATH_PREFIX
Public Instance Methods
() → bool
Source
# File lib/capsium/package/routes_config.rb, line 75 def dataset_route? kind == :dataset end
() → bool
Source
# File lib/capsium/package/routes_config.rb, line 92 def dependency_reference? resource.is_a?(String) && resource.include?("://") end
Whether the resource addresses content of a dependency package (“<dependency-guid>/<path>” — a URI rather than a package-relative path).
(String package_path) → String?
Source
# File lib/capsium/package/routes_config.rb, line 102 def fs_path(package_path) return unless resource File.join(package_path, resource) end
() → bool
Source
# File lib/capsium/package/routes_config.rb, line 79 def handler_route? kind == :handler end
() → bool
Source
# File lib/capsium/package/routes_config.rb, line 97 def inherited? dependency_reference? || !remap.nil? || !response_rewrite.nil? || !response_headers.nil? || !request_headers.nil? end
Whether the route carries route-inheritance attributes.
() → (:resource | :dataset | :handler)
Source
# File lib/capsium/package/routes_config.rb, line 68 def kind return :resource if resource return :dataset if dataset :handler end
(Manifest manifest) → String?
Source
# File lib/capsium/package/routes_config.rb, line 108 def mime(manifest) manifest.type_for(resource) end
() → String?
Source
# File lib/capsium/package/routes_config.rb, line 85 def serving_path remap || path end
The URL path this route answers at: the remapped path when the route remaps an inherited route, its own path otherwise.
(String package_path, Storage storage, ?merged_view: MergedView? merged_view) → void
Source
# File lib/capsium/package/routes_config.rb, line 112 def validate_target(package_path, storage, merged_view: nil) return if handler_route? return if dependency_reference? if dataset_route? return if storage.dataset(dataset) raise Error, "Route dataset does not exist: #{dataset}" end validate_resource_target(package_path, merged_view) end