Class: Certmeister::Rack::App
- Inherits:
-
Object
- Object
- Certmeister::Rack::App
- Defined in:
- lib/certmeister/rack/app.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(ca) ⇒ App
constructor
A new instance of App.
Constructor Details
#initialize(ca) ⇒ App
Returns a new instance of App.
10 11 12 |
# File 'lib/certmeister/rack/app.rb', line 10 def initialize(ca) @ca = ca end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/certmeister/rack/app.rb', line 14 def call(env) req = ::Rack::Request.new(env) if req.path_info == '/ping' if req.request_method == 'GET' ok('PONG') else method_not_allowed end elsif req.path_info == '/ca_cert' if req.request_method == 'GET' ok(@ca.ca_cert_pem, 'application/x-pem-file') else method_not_allowed end elsif req.path_info =~ %r{^/certificate/(.+)} req.params['cn'] = $1 req.params['ip'] = req.ip case req.request_method when 'POST' then sign_action(req) when 'GET' then fetch_action(req) when 'DELETE' then remove_action(req) else method_not_allowed end else not_implemented end end |