Sha256: a80c34854c6c776c79560c5c0c0167c67bd00f4c62cba577f1e2047bc76b3fe1
Contents?: true
Size: 751 Bytes
Versions: 1
Compression:
Stored size: 751 Bytes
Contents
require "rack/alive/version" module Rack class Alive def initialize(app, conditional_block = nil) @app, @path, @conditional_block = app, "/alive", conditional_block end def call(env) if @path == env['PATH_INFO'] alive?(env) else @app.call(env) end end protected def alive_response(sucess) if sucess [200, {'Content-Type' => 'text/plain'}, ["true"]] else [500, {'Content-Type' => 'text/plain'}, ["false"]] end end def alive?(env) is_alive = @conditional_block.respond_to?(:call) ? @conditional_block.call(env) : true alive_response(is_alive) rescue alive_response(false) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rack-alive-0.0.2 | lib/rack/alive.rb |