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}
}

Class Method Summary collapse

Class Method Details

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



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

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



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

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



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

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

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



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

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