Class: Foobara::CommandConnectors::Http
  
  
  
  
  
    - Inherits:
- 
      Foobara::CommandConnector
      
        
        show all
      
    
      - Includes:
- TruncatedInspect
    - Defined in:
- foobara-http-command-connector-1.1.1/src/http.rb,
 foobara-http-command-connector-1.1.1/src/http/cookie.rb,
 foobara-http-command-connector-1.1.1/src/http/request.rb,
 foobara-http-command-connector-1.1.1/src/http/response.rb,
 foobara-http-command-connector-1.1.1/src/http/commands/help.rb,
 foobara-http-command-connector-1.1.1/src/http/commands/describe.rb,
 foobara-http-command-connector-1.1.1/src/http/commands/get_options.rb,
 foobara-http-command-connector-1.1.1/src/http/commands/help/presenter.rb,
 foobara-http-command-connector-1.1.1/src/http/commands/help/presenter/root.rb,
 foobara-http-command-connector-1.1.1/src/http/commands/help/presenter/type.rb,
 foobara-http-command-connector-1.1.1/src/http/response_mutators/set_header.rb,
 foobara-http-command-connector-1.1.1/src/http/commands/help/presenter/error.rb,
 foobara-http-command-connector-1.1.1/src/http/commands/help/presenter/model.rb,
 foobara-http-command-connector-1.1.1/src/http/commands/help/presenter/domain.rb,
 foobara-http-command-connector-1.1.1/src/http/commands/help/presenter/entity.rb,
 foobara-http-command-connector-1.1.1/src/http/commands/help/presenter/command.rb,
 foobara-http-command-connector-1.1.1/src/http/commands/help/result_serializer.rb,
 foobara-http-command-connector-1.1.1/src/http/commands/help/presenter/processor.rb,
 foobara-http-command-connector-1.1.1/src/http/commands/help/presenter/organization.rb,
 foobara-http-command-connector-1.1.1/src/http/commands/help/presenter/request_failed.rb,
 foobara-http-command-connector-1.1.1/src/http/request_mutators/set_input_from_cookie.rb,
 foobara-http-command-connector-1.1.1/src/http/request_mutators/set_input_from_header.rb,
 foobara-http-command-connector-1.1.1/src/http/commands/help/presenter/processor_class.rb,
 foobara-http-command-connector-1.1.1/src/http/request_mutators/set_input_to_proc_result.rb,
 foobara-http-command-connector-1.1.1/src/http/response_mutators/move_attribute_to_cookie.rb,
 foobara-http-command-connector-1.1.1/src/http/response_mutators/move_attribute_to_header.rb,
 foobara-rack-connector-0.1.0/lib/foobara/command_connectors/http/rack.rb,
 foobara-rack-connector-0.1.0/lib/foobara/command_connectors/http/puma_runner.rb,
 foobara-rack-connector-0.1.0/lib/foobara/command_connectors/http/rack/request.rb
 
  Direct Known Subclasses
  Rack
 
Defined Under Namespace
  
    
      Modules: Commands
    
  
    
      Classes: Cookie, MoveAttributeToCookie, MoveAttributeToHeader, Rack, Request, Response, SetHeader, SetInputFromCookie, SetInputFromHeader, SetInputToProcResult
    
  
  Constant Summary
  
  
  TruncatedInspect::MAX_LENGTH
  Class Attribute Summary collapse
  
  Instance Attribute Summary collapse
  
  
  
  
  #authenticator, #capture_unknown_error, #command_registry
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  
  #inspect, truncating
  
  
  
  
  
  
  
  
  
  #all_exposed_commands, #all_exposed_type_names, allowed_rules_to_register, authenticator_registry, #build_command_instance, #build_request, #build_response, #connect, #connect_delayed, #delayed_connections, #desugarize_connect_args, #determine_command_class, find_builtin_command_class, #find_builtin_command_class, #foobara_manifest, #foobara_manifest_in_current_namespace, #lookup_command, #normalize_manifest, #patch_up_broken_parents_for_errors_with_missing_command_parents, #process_delayed_connections, register_allowed_rule, register_authenticator, #request_to_command_instance, #request_to_response, #run_command, #run_request, #serialize_response_body, #set_response_body, to_authenticator, #transform_command_class, #type_from_name
  
  Constructor Details
  
    
  
  
    #initialize(prefix: nil, default_serializers: self.class.default_serializers)  ⇒ Http 
  
  
  
  
    
Returns a new instance of Http.
   
 
  
  
    | 
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55 | # File 'foobara-http-command-connector-1.1.1/src/http.rb', line 33
def initialize(
  prefix: nil,
  default_serializers: self.class.default_serializers,
  **
)
  if prefix
    if prefix.is_a?(::Array)
      prefix = prefix.join("/")
    end
    if prefix.end_with?("/")
      prefix = prefix[0..-2]
    end
    unless prefix.start_with?("/")
      prefix = "/#{prefix}"
    end
    self.prefix = prefix
  end
  super(default_serializers:, **)
end | 
 
  
 
  
    Class Attribute Details
    
      
      
      
  
  
    .default_serializers  ⇒ Object 
  
  
  
 
    
   
  
    Instance Attribute Details
    
      
      
      
  
  
    #prefix  ⇒ Object 
  
  
  
  
    
Returns the value of attribute prefix.
   
 
  
  
    | 
31
32
33 | # File 'foobara-http-command-connector-1.1.1/src/http.rb', line 31
def prefix
  @prefix
end | 
 
    
   
  
    Instance Method Details
    
      
  
  
    | 
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140 | # File 'foobara-http-command-connector-1.1.1/src/http.rb', line 119
def (request)
   = request.
  if .nil? || !.key?("content-type")
    if request.command.respond_to?(:serialize_result)
            if request.command.serializers.include?(Serializers::JsonSerializer)
         = ( || {}).merge("content-type" => "application/json")
      end
    end
  end
  if request.action == "help"
     = ( || {}).merge("content-type" => "text/html")
  end
  if 
    .merge()
  else
    .dup
  end
end | 
 
    
      
  
  
    #mutate_response(response)  ⇒ Object 
  
  
  
  
    | 
107
108
109
110
111
112
113
114
115
116
117 | # File 'foobara-http-command-connector-1.1.1/src/http.rb', line 107
def mutate_response(response)
  super
   = (response.request)
  if &.any?
    response. = (response. || {}).merge()
  else
    response. ||= {}
  end
end | 
 
    
      
  
  
    #request_to_command_class(request)  ⇒ Object 
  
  
  
 
    
      
  
  
    | 
73
74
75
76
77
78
79 | # File 'foobara-http-command-connector-1.1.1/src/http.rb', line 73
def request_to_command_inputs(request)
  if request.method == "OPTIONS"
    { request: }
  else
    super
  end
end | 
 
    
      
  
  
    #run  ⇒ Object 
  
  
  
  
    | 
57
58
59 | # File 'foobara-http-command-connector-1.1.1/src/http.rb', line 57
def run(*, **)
  super(*, prefix:, **)
end | 
 
    
      
  
  
    #set_response_status(response)  ⇒ Object