Class: UU::OS::CMD::SessionHandler

Inherits:
Object
  • Object
show all
Defined in:
uu_os_cmd-2.2.5/lib/uu/os/cmd/session_handler.rb

Overview

Default session handler. As custom handler might be used any class (or object instance) which responds to handle_session method.

Instance Method Summary (collapse)

Instance Method Details

- (void) handle_session(session, http_headers, http_parameters)

This method returns an undefined value.

Propagates data from given session object to corresponding HTTP headers and query parameters.

Parameters:

  • session (#access_token Hash)

    Session can be represented by any object responding to following methods (or Hash containing following keys):

    • #access_token (:accessToken) - Returns value to be used in Authorization header.

  • http_headers (UU::OS::HTTP::HTTPHeaders)

    Modifiable original request headers.

  • http_parameters (UU::OS::HTTP::HTTPQuery)

    Modifiable original request query parameters.



17
18
19
20
21
22
23
24
25
26
# File 'uu_os_cmd-2.2.5/lib/uu/os/cmd/session_handler.rb', line 17

def handle_session(session, http_headers, http_parameters)
  return if session.nil?
  access_token = nil
  if session.kind_of?Hash
    access_token = session[:accessToken]
  else
    access_token = session.access_token if session.respond_to?(:access_token)
  end
  http_headers[:authorization] = access_token if access_token
end