Class: K8::RackApplication
- Inherits:
-
Object
- Object
- K8::RackApplication
- Defined in:
- lib/keight.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
- #each_mapping(&block) ⇒ Object
-
#initialize(urlpath_mapping = [], default_patterns: DEFAULT_PATTERNS, urlpath_cache_size: 0, enable_urlpath_param_range: true) ⇒ RackApplication
constructor
A new instance of RackApplication.
- #lookup(req_path) ⇒ Object
- #show_mappings ⇒ Object
Constructor Details
#initialize(urlpath_mapping = [], default_patterns: DEFAULT_PATTERNS, urlpath_cache_size: 0, enable_urlpath_param_range: true) ⇒ RackApplication
Returns a new instance of RackApplication.
1445 1446 1447 1448 1449 1450 1451 1452 |
# File 'lib/keight.rb', line 1445 def initialize(urlpath_mapping=[], default_patterns: DEFAULT_PATTERNS, urlpath_cache_size: 0, enable_urlpath_param_range: true) #; [!vkp65] mounts urlpath mappings. @mapping = ActionMapping.new(urlpath_mapping, default_patterns: default_patterns, urlpath_cache_size: urlpath_cache_size, enable_urlpath_param_range: enable_urlpath_param_range) end |
Instance Method Details
#call(env) ⇒ Object
1459 1460 1461 1462 1463 |
# File 'lib/keight.rb', line 1459 def call(env) #; [!uvmxe] takes env object. #; [!gpe4g] returns status, headers and content. return handle_request(REQUEST_CLASS.new(env), RESPONSE_CLASS.new) end |
#each_mapping(&block) ⇒ Object
1564 1565 1566 1567 1568 |
# File 'lib/keight.rb', line 1564 def each_mapping(&block) #; [!cgjyv] yields full urlpath pattern, action class and action methods. @mapping.each(&block) self end |
#lookup(req_path) ⇒ Object
1454 1455 1456 1457 |
# File 'lib/keight.rb', line 1454 def lookup(req_path) #; [!o0rnr] returns action class, action methods, urlpath names and values. return @mapping.lookup(req_path) end |
#show_mappings ⇒ Object
1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 |
# File 'lib/keight.rb', line 1570 def show_mappings() #; [!u1g77] returns all mappings as YAML string. req_methods = HTTP_REQUEST_METHODS.values() + [:ANY] s = "" each_mapping do |full_urlpath_pat, action_class, action_methods| arr = req_methods.collect {|req_meth| action_method = action_methods[req_meth] action_method ? "#{req_meth}: #{action_method}" : nil }.compact() s << "- urlpath: #{full_urlpath_pat}\n" s << " class: #{action_class}\n" s << " methods: {#{arr.join(', ')}}\n" s << "\n" end return s end |