Sha256: 341dae40556f92dc87a314bccb8d7f235c57642a614dda524e4c17607dde3125

Contents?: true

Size: 796 Bytes

Versions: 68

Compression:

Stored size: 796 Bytes

Contents

# frozen_string_literal: true

module Bulkrax
  module API
    private

    def api_request?
      true if request.headers['Content-Type'] == 'application/json'
    end

    def token_authenticate!
      return true if request.headers['Authorization'] == "Token: #{ENV['BULKRAX_API_TOKEN']}"
      return json_response('invalid', :unauthorized, "Please supply the authorization token")
    end

    def json_response(method, status = :ok, message = nil)
      case method
      when 'index'
        render json: @importers, status: status
      when 'new', 'edit'
        render json: message, status: :method_not_allowed
      when 'destroy', 'invalid'
        render json: message, status: status
      else
        render json: message || @importer, status: status
      end
    end
  end
end

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
bulkrax-9.0.2 app/controllers/concerns/bulkrax/api.rb
bulkrax-9.0.1 app/controllers/concerns/bulkrax/api.rb
bulkrax-9.0.0 app/controllers/concerns/bulkrax/api.rb
bulkrax-8.2.3 app/controllers/concerns/bulkrax/api.rb
bulkrax-8.2.2 app/controllers/concerns/bulkrax/api.rb
bulkrax-8.3.0 app/controllers/concerns/bulkrax/api.rb
bulkrax-8.2.1 app/controllers/concerns/bulkrax/api.rb
bulkrax-8.2.0 app/controllers/concerns/bulkrax/api.rb
bulkrax-8.1.0 app/controllers/concerns/bulkrax/api.rb
bulkrax-8.0.0 app/controllers/concerns/bulkrax/api.rb
bulkrax-7.0.0 app/controllers/concerns/bulkrax/api.rb
bulkrax-5.5.1 app/controllers/concerns/bulkrax/api.rb
bulkrax-5.4.2 app/controllers/concerns/bulkrax/api.rb
bulkrax-5.3.1 app/controllers/concerns/bulkrax/api.rb
bulkrax-6.0.1 app/controllers/concerns/bulkrax/api.rb
bulkrax-6.0.0 app/controllers/concerns/bulkrax/api.rb
bulkrax-5.5.0 app/controllers/concerns/bulkrax/api.rb
bulkrax-5.4.1 app/controllers/concerns/bulkrax/api.rb
bulkrax-5.4.0 app/controllers/concerns/bulkrax/api.rb
bulkrax-5.3.0 app/controllers/concerns/bulkrax/api.rb