Class: Wurk::ProfilesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/wurk/profiles_controller.rb

Overview

Profiles pane non-JSON endpoints (spec ยง25.4):

GET /profiles/:key/data  โ†’ the stored gzipped gecko JSON, streamed with a
                         gzip Content-Encoding (Firefox profiler pulls
                         this when given a `from-url` source).
GET /profiles/:key       โ†’ upload the profile to the Firefox profiler
                         store and 302 to its public view URL.

:key is "-". The JSON list lives at /api/profiles.

Instance Method Summary collapse

Instance Method Details

#dataObject



20
21
22
23
24
25
26
# File 'app/controllers/wurk/profiles_controller.rb', line 20

def data
  blob = profile_blob(params[:key])
  return head(:not_found) unless blob

  response.headers['Content-Encoding'] = 'gzip'
  send_data blob, type: 'application/json', disposition: 'inline'
end

#showObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/wurk/profiles_controller.rb', line 28

def show
  # GET-shaped for Sidekiq parity, but uploading the profile to the public
  # Firefox profiler store is a side effect โ€” read-only deploys (e.g. the
  # public demo) must not let any visitor exfiltrate profiling data.
  return head(:forbidden) if ::Wurk::Web.config.read_only?

  blob = profile_blob(params[:key])
  return head(:not_found) unless blob

  hash = upload_to_profiler(blob)
  return head(:bad_gateway) unless hash

  redirect_to(format(::Wurk::Web.config.profile_view_url, hash), allow_other_host: true)
end