Class: Getto::Roda::EntryPoint
- Inherits:
-
Object
- Object
- Getto::Roda::EntryPoint
- Defined in:
- lib/getto/roda/entry_point.rb
Overview
:nocov:
Instance Attribute Summary collapse
-
#account ⇒ Object
readonly
Returns the value of attribute account.
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#exception_notifier ⇒ Object
readonly
Returns the value of attribute exception_notifier.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
- #handle(controller) ⇒ Object
-
#initialize(error:, time_zone:, app:, request:, config:, params:, request_logger:, exception_notifier:) ⇒ EntryPoint
constructor
A new instance of EntryPoint.
Constructor Details
#initialize(error:, time_zone:, app:, request:, config:, params:, request_logger:, exception_notifier:) ⇒ EntryPoint
Returns a new instance of EntryPoint.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/getto/roda/entry_point.rb', line 9 def initialize( error:, time_zone:, app:, request:, config:, params:, request_logger:, exception_notifier:) @error = error @time = Getto::Roda::Time.new(now: ::Time.now, time_zone: time_zone) @app = app @request = request @config = config @params = params @request_logger = check_signature(:request_logger, request_logger, [ :debug, :info, :warn, :error, :fatal, ]) @exception_notifier = check_signature(:exception_notifier, exception_notifier, [ :notify_exception, ]) @logger = Getto::Roda::Logger.new end |
Instance Attribute Details
#account ⇒ Object (readonly)
Returns the value of attribute account.
47 48 49 |
# File 'lib/getto/roda/entry_point.rb', line 47 def account @account end |
#app ⇒ Object (readonly)
Returns the value of attribute app.
47 48 49 |
# File 'lib/getto/roda/entry_point.rb', line 47 def app @app end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
47 48 49 |
# File 'lib/getto/roda/entry_point.rb', line 47 def config @config end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
47 48 49 |
# File 'lib/getto/roda/entry_point.rb', line 47 def error @error end |
#exception_notifier ⇒ Object (readonly)
Returns the value of attribute exception_notifier.
47 48 49 |
# File 'lib/getto/roda/entry_point.rb', line 47 def exception_notifier @exception_notifier end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
47 48 49 |
# File 'lib/getto/roda/entry_point.rb', line 47 def logger @logger end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
47 48 49 |
# File 'lib/getto/roda/entry_point.rb', line 47 def params @params end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
47 48 49 |
# File 'lib/getto/roda/entry_point.rb', line 47 def request @request end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
47 48 49 |
# File 'lib/getto/roda/entry_point.rb', line 47 def time @time end |
Instance Method Details
#handle(controller) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/getto/roda/entry_point.rb', line 53 def handle(controller) params.merge! parse_params.to_h @account = detect_account init_controller(controller).action rescue error => e error! e if e.status >= 500 exception_notifier.notify(e, data: request_data) end app.response.status = e.status {message: e..split(":").first} rescue Exception => e error! e exception_notifier.notify_exception(e, data: request_data) raise e ensure if @error_data @request_logger.error(name: :handle){ request_data } else @request_logger.info(name: :handle){ request_data } end end |