File: results_controller.rb

package info (click to toggle)
ruby-peek 1.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 352 kB
  • sloc: ruby: 534; makefile: 7; sh: 2
file content (25 lines) | stat: -rw-r--r-- 527 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module Peek
  class ResultsController < ApplicationController
    before_action :restrict_non_access

    def show
      respond_to do |format|
        format.json do
          if request.xhr?
            render json: Peek.adapter.get(params[:request_id])
          else
            render nothing: true, status: :not_found
          end
        end
      end
    end

    private

    def restrict_non_access
      unless peek_enabled?
        raise ActionController::RoutingError.new('Not Found')
      end
    end
  end
end