lib/hara/app.rb in hara-0.2.1 vs lib/hara/app.rb in hara-0.2.2

- old
+ new

@@ -59,11 +59,11 @@ end def after_action action, args end - def on_close + def on_close close_info = {} end ################## #like method_missing @@ -75,10 +75,15 @@ #get client headers def headers handshake.headers_downcased end + # close connection + def close code = nil, body = nil + @socket.close code, body + end + #below are internal functions(should not been overriding) def initialize handshake, socket @handshake = handshake @socket = socket @@ -108,11 +113,15 @@ else action_missing action, *args end end + def set_close_info close_info + @_close_info = close_info + end + def app_finalizer - on_close + on_close @_close_info ensure @socket.close if @socket end end end