Sha256: 3ce80d2317b4f37feebe1aed5f1e8051f8c41cc1946ed8d55f4650cfccfb6ba9

Contents?: true

Size: 755 Bytes

Versions: 7

Compression:

Stored size: 755 Bytes

Contents

require_dependency "ctws/application_controller"

module Ctws
  class CtwsController < ApplicationController
    include Response
    include ExceptionHandler
    include HttpAcceptLanguage::AutoLocale

    # Generic API stuff here

    # called before every action on controllers
    before_action :authorize_request
    skip_before_action :authorize_request, only: [:raise_not_found!]
    attr_reader :current_user

    def raise_not_found!
      raise Ctws::ExceptionHandler::RoutingError, ("#{Ctws::Message.unmatched_route(params[:unmatched_route])}")
    end
    private

    # Check for valid request token and return user
    def authorize_request
      @current_user = (Ctws::AuthorizeApiRequest.new(request.headers).call)[:user]
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ctws-0.3.0.beta app/controllers/ctws/ctws_controller.rb
ctws-0.2.3.beta app/controllers/ctws/ctws_controller.rb
ctws-0.2.2.beta app/controllers/ctws/ctws_controller.rb
ctws-0.2.1.beta app/controllers/ctws/ctws_controller.rb
ctws-0.2.0.beta app/controllers/ctws/ctws_controller.rb
ctws-0.1.14.beta app/controllers/ctws/ctws_controller.rb
ctws-0.1.13.alpha app/controllers/ctws/ctws_controller.rb