Tried to reduce gap between both EWSGI proposals
Re-adapt the Spec-compliant solution (instead of Lib-compliant solution). Thus no more 100% deferred interface. Rename EWSGI_RESPONSE into EWSGI_RESPONSE_BUFFER Added in extra/response-as-result/ an copy/paste from the implementation of Paul's proposal (not up to date with Paul's spec). But this is mainly for information and tests. Removed part of the ewsgi/specification interfaces ... to be able to test EWSGI compliant library against the pure specification (experimental). Renamed most of the GW_... into EWSGI_...
This commit is contained in:
@@ -8,73 +8,19 @@ note
|
||||
deferred class
|
||||
EWSGI_APPLICATION
|
||||
|
||||
feature -- Process request
|
||||
|
||||
process (env: EWSGI_ENVIRONMENT; a_input: EWSGI_INPUT_STREAM; a_output: EWSGI_OUTPUT_STREAM)
|
||||
-- Process request with environment `env', and i/o streams `a_input' and `a_output'
|
||||
local
|
||||
rescued: BOOLEAN
|
||||
req: detachable like new_request
|
||||
res: detachable like new_response
|
||||
do
|
||||
if not rescued then
|
||||
pre_execute (env)
|
||||
req := new_request (env, a_input)
|
||||
res := new_response (req, a_output)
|
||||
execute (req, res)
|
||||
post_execute (req, res)
|
||||
else
|
||||
rescue_execute (req, res, (create {EXCEPTION_MANAGER}).last_exception)
|
||||
end
|
||||
if res /= Void then
|
||||
res.commit (a_output)
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Execution
|
||||
|
||||
execute (req: EWSGI_REQUEST; res: EWSGI_RESPONSE_STREAM)
|
||||
execute (req: EWSGI_REQUEST; res: EWSGI_RESPONSE_BUFFER)
|
||||
-- Execute the request
|
||||
-- See `req.input' for input stream
|
||||
-- `req.environment' for the Gateway environment
|
||||
-- and `res.output' for output stream
|
||||
deferred
|
||||
end
|
||||
|
||||
pre_execute (env: EWSGI_ENVIRONMENT)
|
||||
-- Operation processed before `execute'
|
||||
-- and `res' for the output buffer
|
||||
require
|
||||
env_attached: env /= Void
|
||||
do
|
||||
end
|
||||
|
||||
post_execute (req: detachable EWSGI_REQUEST; res: detachable EWSGI_RESPONSE_STREAM)
|
||||
-- Operation processed after `execute', or after `rescue_execute'
|
||||
do
|
||||
end
|
||||
|
||||
rescue_execute (req: detachable EWSGI_REQUEST; res: detachable EWSGI_RESPONSE_STREAM; a_exception: detachable EXCEPTION)
|
||||
-- Operation processed on rescue of `execute'
|
||||
do
|
||||
post_execute (req, res)
|
||||
end
|
||||
|
||||
feature -- Factory
|
||||
|
||||
new_request (env: EWSGI_ENVIRONMENT; a_input: EWSGI_INPUT_STREAM): EWSGI_REQUEST
|
||||
-- New Request context based on `env' and `a_input'
|
||||
--| note: you can redefine this function to create your own
|
||||
--| descendant of EWSGI_REQUEST , or even to reuse/recycle existing
|
||||
--| instance of EWSGI_REQUEST
|
||||
deferred
|
||||
end
|
||||
|
||||
new_response (req: EWSGI_REQUEST; a_output: EWSGI_OUTPUT_STREAM): EWSGI_RESPONSE_STREAM
|
||||
-- New Response based on `req' and `a_output'
|
||||
--| note: you can redefine this function to create your own
|
||||
--| descendant of EWSGI_RESPONSE_STREAM , or even to reuse/recycle existing
|
||||
--| instance of EWSGI_RESPONSE_STREAM
|
||||
res_status_unset: not res.status_is_set
|
||||
deferred
|
||||
ensure
|
||||
res_status_set: res.status_is_set
|
||||
res_committed: res.message_committed
|
||||
end
|
||||
|
||||
note
|
||||
|
||||
Reference in New Issue
Block a user