Class: Loginator::Request

Inherits:
Struct
  • Object
show all
Includes:
JsonableStruct, Transaction
Defined in:
lib/loginator/request.rb

Overview

A request is a tuple of a (UUID, Timestamp, Path, Parameters). Requests parameters are defined subjectively by the user. For example, in the example Rack middleware (#Rack#Rack::Loginator#Rack::Loginator::Logging), we define params as the request body (our HTTP APIs tend to accept JSON bodies as opposed to parameters attached to the URL). You may also wish to consider part of the HTTP headers as a request parameter.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Transaction

#format_time, #uuid

Methods included from JsonableStruct

included, #to_json

Constructor Details

#initialize(request_id = uuid, timestamp = format_time, path = nil, params = {}) ⇒ Request

Create a new Loginator::Request

Parameters:

  • request_id (String) (defaults to: uuid)

    (SecureRandom.uuid) Unique identifier for the request

  • timestamp (Float) (defaults to: format_time)

    (Time.now.utc.to_f) Time of the request

  • path (String) (defaults to: nil)

    (nil) Path associated with the request

  • params (String) (defaults to: {})

    ({}) Parameters of the request



21
22
23
# File 'lib/loginator/request.rb', line 21

def initialize(request_id = uuid, timestamp = format_time, path = nil, params = {})
  super
end

Instance Attribute Details

#paramsObject

Returns the value of attribute params

Returns:

  • (Object)

    the current value of params



12
13
14
# File 'lib/loginator/request.rb', line 12

def params
  @params
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



12
13
14
# File 'lib/loginator/request.rb', line 12

def path
  @path
end

#request_idObject

Returns the value of attribute request_id

Returns:

  • (Object)

    the current value of request_id



12
13
14
# File 'lib/loginator/request.rb', line 12

def request_id
  @request_id
end

#timestampObject

Returns the value of attribute timestamp

Returns:

  • (Object)

    the current value of timestamp



12
13
14
# File 'lib/loginator/request.rb', line 12

def timestamp
  @timestamp
end