summaryrefslogtreecommitdiff
path: root/app/controllers/admin/requests_profiles_controller.rb
blob: b60cb7ff9c2c7b25fca4144ba9867e6a0352a7bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

class Admin::RequestsProfilesController < Admin::ApplicationController
  feature_category :not_owned # rubocop:todo Gitlab/AvoidFeatureCategoryNotOwned

  def index
    @profile_token = Gitlab::RequestProfiler.profile_token
    @profiles      = Gitlab::RequestProfiler.all.group_by(&:request_path)
  end

  def show
    clean_name = Rack::Utils.clean_path_info(params[:name])
    profile    = Gitlab::RequestProfiler.find(clean_name)

    unless profile && profile.content_type
      return redirect_to admin_requests_profiles_path, alert: 'Profile not found'
    end

    send_file profile.file_path, type: "#{profile.content_type}; charset=utf-8", disposition: 'inline'
  end
end