Sha256: 21e731cc2525c2d7639f8632937dbd5dcf7b02a088da2684ca2cdd5409b251a9

Contents?: true

Size: 702 Bytes

Versions: 1

Compression:

Stored size: 702 Bytes

Contents

require 'sipatra'
require 'logger'

module Kipatra
  class SipatraServlet < Kipatra::Cipango::SipServlet
    def doRequest(req)
      invoke req, :do_request
    end

    def doResponse(req)
      invoke req, :do_response
    end

    private

    def invoke(msg, method_name)
      begin
        log = Logger.new(STDOUT)
        app = Sipatra::Application::new
        session = msg.session
        app.set_bindings session.servlet_context, session.servlet_context.getAttribute(Kipatra::Cipango::SipServlet::SIP_FACTORY), session, msg, log
        app.send method_name
      rescue => e
        # TODO XXX
        puts "SIPATRA EXCEPTION: #{e}\n#{e.backtrace.join("\n")}"

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kipatra-0.1.2 lib/kipatra/sipatra.rb