10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/controllers/profiler/api/slave_proxy_controller.rb', line 10
def forward
proxy = Cluster::SlaveProxy.new(params[:slave_name])
sub_path = params[:path].to_s
full_path = "/_profiler/api/#{sub_path}"
result = case request.method
when "GET"
proxy.get_json(full_path, request.query_parameters.to_h)
when "POST"
proxy.post_json(full_path, parsed_body)
when "PATCH"
proxy.patch_json(full_path, parsed_body)
when "DELETE"
proxy.delete_json(full_path)
else
return head :method_not_allowed
end
render json: result
rescue Profiler::Error => e
render json: { error: e.message }, status: :bad_gateway
rescue => e
render json: { error: "Proxy error: #{e.message}" }, status: :bad_gateway
end
|