Class: SqAuth::SqAuthServer::BasicServer

Inherits:
Object
  • Object
show all
Defined in:
lib/sq_auth/sq_auth_server_interface/basic_server.rb

Constant Summary collapse

SERVER_INTERFACE =
{
  check_connection: {path: "health", method: :get},
  check_role: {path: "check_role", method: :post},
  get_roles: {path: "get_roles", method: :get}
}

Class Method Summary collapse

Class Method Details

.init_request(specification, host_options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/sq_auth/sq_auth_server_interface/basic_server.rb', line 10

def self.init_request specification, host_options = {}
  options = {}
  options[:host] = host_options[:host]
  options[:port] = host_options[:port]
  options[:username] = host_options[:username]
  options[:password] = host_options[:password]
  options[:https] = host_options[:https]
  options[:path] = specification[:path]
  options[:method] = specification[:method]
  SqAuthRequest.new options
end

.method_missing(m, *args, &block) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/sq_auth/sq_auth_server_interface/basic_server.rb', line 32

def self.method_missing m, *args, &block
  if SERVER_INTERFACE[m]
    use_interface(SERVER_INTERFACE[m], *args)
  else
    super
  end
end

.sq_auth_host(host_options) ⇒ Object



22
23
24
# File 'lib/sq_auth/sq_auth_server_interface/basic_server.rb', line 22

def self.sq_auth_host host_options
  {host: host_options[:host], port: host_options[:port]}
end

.use_interface(interface, query, host_options = {}) ⇒ Object



26
27
28
29
30
# File 'lib/sq_auth/sq_auth_server_interface/basic_server.rb', line 26

def self.use_interface interface, query, host_options = {}
  interface[:requests] ||= {}
  interface[:requests][sq_auth_host(host_options)] ||= init_request(interface, host_options)
  interface[:requests][sq_auth_host(host_options)].request query
end