Class: Faalis::API::Base

Inherits:
Grape::API
  • Object
show all
Defined in:
lib/faalis/api.rb

Overview

autoload UsersAPI, "faalis/api/users_api" autoload GroupsAPI, "faalis/api/groups_api" autoload PermissionsAPI, "faalis/api/permissions_api"

Class Method Summary (collapse)

Class Method Details

+ (Object) setup_api



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/faalis/api.rb', line 29

def self.setup_api

  # TODO: Allow user to configure this section
  version 'v1', :vendor => "Yellowen"
  format :json
  default_format :json

  # TODO: Give this class a logger

  helpers do

    def warden
      env['warden']
    end

    def current_user
      warden.user
    end

    def authenticated_user
      if warden.authenticated?
        return true
      else
        error!('401 Unauthorized', 401)
      end
    end

  end

end