Class: ForestAdminAgent::Routes::Workflow::WorkflowExecutorProxy
- Inherits:
-
AbstractAuthenticatedRoute
- Object
- AbstractRoute
- AbstractAuthenticatedRoute
- ForestAdminAgent::Routes::Workflow::WorkflowExecutorProxy
- Defined in:
- lib/forest_admin_agent/routes/workflow/workflow_executor_proxy.rb
Overview
Generic proxy: forwards any sub-path/verb under AGENT_PREFIX to the executor verbatim, so a
new executor route needs no change here. Mounted only when workflow_executor_url is set.
Constant Summary collapse
- AGENT_PREFIX =
'/_internal/executor'.freeze
- SKIPPED_HEADERS =
Never forwarded (request or response): hop-by-hop, Host, and body-framing headers. Faraday and
render json:set their own length and de/recompress the body, so relaying the upstream length/encoding would mismatch the bytes we actually send — and forwarding accept-encoding would disable Faraday's transparent gzip decompression. %w[ connection keep-alive transfer-encoding upgrade te trailer proxy-authenticate proxy-authorization host content-length content-encoding accept-encoding ].freeze
- UNSAFE_PATH_FRAGMENTS =
Fragments that could let the wildcard leave the executor origin once decoded.
['..', '%2e', '%2E', '\\', "\0"].freeze
- OPEN_TIMEOUT =
2- REQUEST_TIMEOUT =
120
Instance Method Summary collapse
Methods inherited from AbstractAuthenticatedRoute
#build, #format_attributes, #redacted_full_projection, #redacted_projection_with_pks
Methods inherited from AbstractRoute
#add_route, #build, #initialize, #routes
Constructor Details
This class inherits a constructor from ForestAdminAgent::Routes::AbstractRoute
Instance Method Details
#handle_request(args = {}) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/forest_admin_agent/routes/workflow/workflow_executor_proxy.rb', line 38 def handle_request(args = {}) build(args) method = (args[:method] || 'get').to_s.downcase.to_sym response = forward(method, build_target_url(args), args) { content: response.body, status: response.status, headers: forwarded_response_headers(response) } end |
#setup_routes ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/forest_admin_agent/routes/workflow/workflow_executor_proxy.rb', line 25 def setup_routes return self unless executor_configured? add_route( 'forest_workflow_executor_proxy', :all, "#{AGENT_PREFIX}/*path", ->(args) { handle_request(args) } ) self end |