Class: Foobara::CommandConnectors::Http
- Inherits:
-
Foobara::CommandConnector
show all
- Includes:
- TruncatedInspect
- Defined in:
- foobara-http-command-connector-0.0.23/src/http.rb,
foobara-http-command-connector-0.0.23/src/http/cookie.rb,
foobara-http-command-connector-0.0.23/src/http/request.rb,
foobara-http-command-connector-0.0.23/src/http/response.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help.rb,
foobara-http-command-connector-0.0.23/src/http/commands/describe.rb,
foobara-http-command-connector-0.0.23/src/http/commands/get_options.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/root.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/type.rb,
foobara-http-command-connector-0.0.23/src/http/response_mutators/set_header.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/error.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/model.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/domain.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/entity.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/command.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/result_serializer.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/processor.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/organization.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/request_failed.rb,
foobara-http-command-connector-0.0.23/src/http/request_mutators/set_input_from_cookie.rb,
foobara-http-command-connector-0.0.23/src/http/request_mutators/set_input_from_header.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/processor_class.rb,
foobara-http-command-connector-0.0.23/src/http/response_mutators/move_attribute_to_cookie.rb,
foobara-http-command-connector-0.0.23/src/http/response_mutators/move_attribute_to_header.rb,
foobara-rack-connector-0.0.10/lib/foobara/command_connectors/http/rack.rb,
foobara-rack-connector-0.0.10/lib/foobara/command_connectors/http/puma_runner.rb,
foobara-rack-connector-0.0.10/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
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, allowed_rules_to_register, #authenticate, authenticator_registry, #build_command, #build_request, #build_response, #connect, #connect_delayed, #delayed_connections, find_builtin_command_class, #find_builtin_command_class, #foobara_manifest, #lookup_command, #normalize_manifest, #patch_up_broken_parents_for_errors_with_missing_command_parents, #process_delayed_connections, register_allowed_rule, register_authenticator, #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-0.0.23/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-0.0.23/src/http.rb', line 31
def prefix
@prefix
end
|
Instance Method Details
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
# File 'foobara-http-command-connector-0.0.23/src/http.rb', line 115
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
.merge()
else
.dup
end
end
|
#mutate_response(response) ⇒ Object
103
104
105
106
107
108
109
110
111
112
113
|
# File 'foobara-http-command-connector-0.0.23/src/http.rb', line 103
def mutate_response(response)
super
= (response.request)
if &.any?
response. = (response. || {}).merge()
else
response. ||= {}
end
end
|
#request_to_command(request) ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'foobara-http-command-connector-0.0.23/src/http.rb', line 61
def request_to_command(request)
if request.method == "OPTIONS"
return Foobara::CommandConnectors::Http::Commands::GetOptions.new(request:)
end
command = super
if request.action == "help"
request.("content-type", "text/html")
command.class.serializers = [Commands::Help::ResultSerializer]
end
command
end
|
#run ⇒ Object
57
58
59
|
# File 'foobara-http-command-connector-0.0.23/src/http.rb', line 57
def run(*, **)
super(*, prefix:, **)
end
|
#set_response_status(response) ⇒ Object