Class: Capsium::Package::Route
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Capsium::Package::Route
- Defined in:
- lib/capsium/package/routes_config.rb,
sig/capsium/package/routes_config.rbs
Overview
A single route entry (ARCHITECTURE.md section 4). Kinds are discriminated by key, MECE: static file, dataset route, or dynamic handler (accepted-and-ignored; reactors respond 501). Route inheritance attributes per 05x-routing.
Constant Summary collapse
- DATASET_PATH_PREFIX =
"/api/v1/data/"
Instance Attribute Summary collapse
-
#access_control ⇒ Hash[String, untyped]?
Returns the value of attribute access_control.
-
#dataset ⇒ String?
Returns the value of attribute dataset.
-
#handler ⇒ String?
Returns the value of attribute handler.
-
#headers ⇒ Hash[String, String]?
Returns the value of attribute headers.
-
#headers_file ⇒ String?
Returns the value of attribute headers_file.
-
#http_method ⇒ String?
Returns the value of attribute http_method.
-
#path ⇒ String?
Returns the value of attribute path.
-
#remap ⇒ String?
Returns the value of attribute remap.
-
#request_headers ⇒ Hash[String, String]?
Returns the value of attribute request_headers.
-
#resource ⇒ String?
Returns the value of attribute resource.
-
#response_headers ⇒ Hash[String, String]?
Returns the value of attribute response_headers.
-
#response_rewrite ⇒ ResponseRewrite?
Returns the value of attribute response_rewrite.
-
#visibility ⇒ String
Returns the value of attribute visibility.
Class Method Summary collapse
Instance Method Summary collapse
- #dataset_route? ⇒ Boolean
-
#dependency_reference? ⇒ Boolean
Whether the resource addresses content of a dependency package ("
/ " — a URI rather than a package-relative path). - #fs_path(package_path) ⇒ String?
- #handler_route? ⇒ Boolean
-
#inherited? ⇒ Boolean
Whether the route carries route-inheritance attributes.
- #initialize ⇒ Object constructor
- #kind ⇒ :resource, ...
- #mime(manifest) ⇒ String?
-
#serving_path ⇒ String?
The URL path this route answers at: the remapped path when the route remaps an inherited route, its own path otherwise.
- #to_hash ⇒ Hash[String, untyped]
- #to_json ⇒ String
- #validate_target(package_path, storage, merged_view: nil) ⇒ void
Constructor Details
#initialize ⇒ Object
37 |
# File 'sig/capsium/package/routes_config.rbs', line 37
def initialize: (?path: String? path, ?resource: String? resource,
|
Instance Attribute Details
#access_control ⇒ Hash[String, untyped]?
Returns the value of attribute access_control.
29 30 31 |
# File 'sig/capsium/package/routes_config.rbs', line 29 def access_control @access_control end |
#dataset ⇒ String?
Returns the value of attribute dataset.
28 29 30 |
# File 'sig/capsium/package/routes_config.rbs', line 28 def dataset @dataset end |
#handler ⇒ String?
Returns the value of attribute handler.
31 32 33 |
# File 'sig/capsium/package/routes_config.rbs', line 31 def handler @handler end |
#headers ⇒ Hash[String, String]?
Returns the value of attribute headers.
25 26 27 |
# File 'sig/capsium/package/routes_config.rbs', line 25 def headers @headers end |
#headers_file ⇒ String?
Returns the value of attribute headers_file.
26 27 28 |
# File 'sig/capsium/package/routes_config.rbs', line 26 def headers_file @headers_file end |
#http_method ⇒ String?
Returns the value of attribute http_method.
30 31 32 |
# File 'sig/capsium/package/routes_config.rbs', line 30 def http_method @http_method end |
#path ⇒ String?
Returns the value of attribute path.
23 24 25 |
# File 'sig/capsium/package/routes_config.rbs', line 23 def path @path end |
#remap ⇒ String?
Returns the value of attribute remap.
32 33 34 |
# File 'sig/capsium/package/routes_config.rbs', line 32 def remap @remap end |
#request_headers ⇒ Hash[String, String]?
Returns the value of attribute request_headers.
35 36 37 |
# File 'sig/capsium/package/routes_config.rbs', line 35 def request_headers @request_headers end |
#resource ⇒ String?
Returns the value of attribute resource.
24 25 26 |
# File 'sig/capsium/package/routes_config.rbs', line 24 def resource @resource end |
#response_headers ⇒ Hash[String, String]?
Returns the value of attribute response_headers.
34 35 36 |
# File 'sig/capsium/package/routes_config.rbs', line 34 def response_headers @response_headers end |
#response_rewrite ⇒ ResponseRewrite?
Returns the value of attribute response_rewrite.
33 34 35 |
# File 'sig/capsium/package/routes_config.rbs', line 33 def response_rewrite @response_rewrite end |
#visibility ⇒ String
Returns the value of attribute visibility.
27 28 29 |
# File 'sig/capsium/package/routes_config.rbs', line 27 def visibility @visibility end |
Class Method Details
.from_json ⇒ instance
48 |
# File 'sig/capsium/package/routes_config.rbs', line 48
def self.from_json: (String json) -> instance
|
Instance Method Details
#dataset_route? ⇒ Boolean
75 76 77 |
# File 'lib/capsium/package/routes_config.rb', line 75 def dataset_route? kind == :dataset end |
#dependency_reference? ⇒ Boolean
Whether the resource addresses content of a dependency package
("
92 93 94 |
# File 'lib/capsium/package/routes_config.rb', line 92 def dependency_reference? resource.is_a?(String) && resource.include?("://") end |
#fs_path(package_path) ⇒ String?
102 103 104 105 106 |
# File 'lib/capsium/package/routes_config.rb', line 102 def fs_path(package_path) return unless resource File.join(package_path, resource) end |
#handler_route? ⇒ Boolean
79 80 81 |
# File 'lib/capsium/package/routes_config.rb', line 79 def handler_route? kind == :handler end |
#inherited? ⇒ Boolean
Whether the route carries route-inheritance attributes.
97 98 99 100 |
# 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 |
#kind ⇒ :resource, ...
68 69 70 71 72 73 |
# File 'lib/capsium/package/routes_config.rb', line 68 def kind return :resource if resource return :dataset if dataset :handler end |
#mime(manifest) ⇒ String?
108 109 110 |
# File 'lib/capsium/package/routes_config.rb', line 108 def mime(manifest) manifest.type_for(resource) end |
#serving_path ⇒ String?
The URL path this route answers at: the remapped path when the route remaps an inherited route, its own path otherwise.
85 86 87 |
# File 'lib/capsium/package/routes_config.rb', line 85 def serving_path remap || path end |
#to_hash ⇒ Hash[String, untyped]
75 |
# File 'sig/capsium/package/routes_config.rbs', line 75
def to_hash: () -> Hash[String, untyped]
|
#to_json ⇒ String
74 |
# File 'sig/capsium/package/routes_config.rbs', line 74
def to_json: (*untyped args) -> String
|
#validate_target(package_path, storage, merged_view: nil) ⇒ void
This method returns an undefined value.
112 113 114 115 116 117 118 119 120 121 122 |
# 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 |