Added an implementation folder in ewsgi_spec, mainly to provide default implementation just to save the developer of connector some time.
changed structured
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
note
|
||||
description: "Summary description for {EWSGI_AGENT_APPLICATION}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
GW_AGENT_APPLICATION
|
||||
|
||||
inherit
|
||||
GW_APPLICATION_IMP
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
make (a_callback: like callback)
|
||||
-- Initialize `Current'.
|
||||
do
|
||||
callback := a_callback
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
callback: PROCEDURE [ANY, TUPLE [req: like new_request; res: like new_response]]
|
||||
-- Procedure called on `execute'
|
||||
|
||||
execute (req: like new_request; res: like new_response)
|
||||
-- Execute the request
|
||||
do
|
||||
callback.call ([req, res])
|
||||
end
|
||||
|
||||
invariant
|
||||
callback_attached: callback /= Void
|
||||
|
||||
note
|
||||
copyright: "2011-2011, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
@@ -0,0 +1,69 @@
|
||||
note
|
||||
description: "Summary description for {GW_APPLICATION_IMP} "
|
||||
legal: "See notice at end of class."
|
||||
status: "See notice at end of class."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
GW_APPLICATION_IMP
|
||||
|
||||
inherit
|
||||
EWSGI_APPLICATION
|
||||
redefine
|
||||
process,
|
||||
rescue_execute
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
request_count: INTEGER
|
||||
-- Request count
|
||||
|
||||
feature -- Execution
|
||||
|
||||
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'
|
||||
do
|
||||
request_count := request_count + 1
|
||||
Precursor (env, a_input, a_output)
|
||||
end
|
||||
|
||||
rescue_execute (req: detachable EWSGI_REQUEST; res: detachable EWSGI_RESPONSE; a_exception: detachable EXCEPTION)
|
||||
-- Operation processed on rescue of `execute'
|
||||
do
|
||||
if
|
||||
req /= Void and res /= Void
|
||||
and a_exception /= Void and then attached a_exception.exception_trace as l_trace
|
||||
then
|
||||
res.write_header ({HTTP_STATUS_CODE}.internal_server_error, Void)
|
||||
res.write_string ("<pre>" + l_trace + "</pre>")
|
||||
end
|
||||
Precursor (req, res, a_exception)
|
||||
end
|
||||
|
||||
feature -- Factory
|
||||
|
||||
new_request (env: EWSGI_ENVIRONMENT; a_input: EWSGI_INPUT_STREAM): EWSGI_REQUEST
|
||||
do
|
||||
create {GW_REQUEST_IMP} Result.make (env, a_input)
|
||||
Result.execution_variables.set_variable (request_count.out, "REQUEST_COUNT")
|
||||
end
|
||||
|
||||
new_response (req: EWSGI_REQUEST; a_output: EWSGI_OUTPUT_STREAM): EWSGI_RESPONSE
|
||||
do
|
||||
create {GW_RESPONSE_IMP} Result.make (a_output)
|
||||
end
|
||||
|
||||
;note
|
||||
copyright: "2011-2011, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
|
||||
end
|
||||
@@ -0,0 +1,53 @@
|
||||
note
|
||||
description: "Summary description for {GW_IN_MEMORY_RESPONSE_APPLICATION}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
GW_IN_MEMORY_RESPONSE_APPLICATION
|
||||
|
||||
inherit
|
||||
EWSGI_APPLICATION
|
||||
redefine
|
||||
process
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
request_count: INTEGER
|
||||
-- Request count
|
||||
|
||||
feature -- Execution
|
||||
|
||||
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'
|
||||
do
|
||||
request_count := request_count + 1
|
||||
Precursor (env, a_input, a_output)
|
||||
end
|
||||
|
||||
feature -- Factory
|
||||
|
||||
new_request (env: EWSGI_ENVIRONMENT; a_input: EWSGI_INPUT_STREAM): EWSGI_REQUEST
|
||||
do
|
||||
create {GW_REQUEST_IMP} Result.make (env, a_input)
|
||||
Result.execution_variables.set_variable (request_count.out, "REQUEST_COUNT")
|
||||
end
|
||||
|
||||
new_response (req: EWSGI_REQUEST; a_output: EWSGI_OUTPUT_STREAM): GW_IN_MEMORY_RESPONSE
|
||||
do
|
||||
create {GW_IN_MEMORY_RESPONSE} Result.make
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2011, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
Reference in New Issue
Block a user