Sha256: 41ef81639a84582307fb195b7af37f56b83ba50baf680d7a9e7f64c80639dc9f

Contents?: true

Size: 719 Bytes

Versions: 8

Compression:

Stored size: 719 Bytes

Contents

require_dependency "ctws/application_controller"

module Ctws
  class CtwsController < ApplicationController
    include Response
    include ExceptionHandler
    # 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

8 entries across 8 versions & 1 rubygems

Version Path
ctws-0.1.12.alpha app/controllers/ctws/ctws_controller.rb
ctws-0.1.11.alpha app/controllers/ctws/ctws_controller.rb
ctws-0.1.10.alpha app/controllers/ctws/ctws_controller.rb
ctws-0.1.9.alpha app/controllers/ctws/ctws_controller.rb
ctws-0.1.8.alpha app/controllers/ctws/ctws_controller.rb
ctws-0.1.7.alpha app/controllers/ctws/ctws_controller.rb
ctws-0.1.6.alpha app/controllers/ctws/ctws_controller.rb
ctws-0.1.5.alpha app/controllers/ctws/ctws_controller.rb