Class: Shikibu::Middleware::RackApp
- Inherits:
-
Object
- Object
- Shikibu::Middleware::RackApp
- Defined in:
- lib/shikibu/middleware/rack_app.rb
Overview
Rack application for handling CloudEvents
Constant Summary collapse
- CONTENT_TYPE_JSON =
'application/json'- CONTENT_TYPE_CLOUDEVENTS =
'application/cloudevents+json'
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app = nil) ⇒ RackApp
constructor
A new instance of RackApp.
Constructor Details
#initialize(app = nil) ⇒ RackApp
Returns a new instance of RackApp.
31 32 33 |
# File 'lib/shikibu/middleware/rack_app.rb', line 31 def initialize(app = nil) @app = app end |
Instance Method Details
#call(env) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/shikibu/middleware/rack_app.rb', line 35 def call(env) request = Rack::Request.new(env) path = request.path_info case path when '/shikibu/events', '/events' handle_event(request) when '/shikibu/health', '/health' health_check when '/shikibu/health/live', '/health/live' liveness_check when '/shikibu/health/ready', '/health/ready' readiness_check when %r{^/shikibu/workflows/([^/]+)/status$} handle_status(::Regexp.last_match(1)) when %r{^/shikibu/workflows/([^/]+)/result$} handle_result(::Regexp.last_match(1)) when %r{^/shikibu/workflows/([^/]+)/cancel$} handle_cancel(request, ::Regexp.last_match(1)) else # Pass to next middleware if available @app ? @app.call(env) : not_found end end |