merged from upstream

This commit is contained in:
Colin Adams
2012-12-08 08:25:47 +00:00
51 changed files with 472 additions and 269 deletions

View File

@@ -1,40 +0,0 @@
note
description: "Logging filter."
author: "Olivier Ligot"
date: "$Date$"
revision: "$Revision$"
class
LOGGING_FILTER
inherit
WSF_FILTER
feature -- Basic operations
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute the filter
local
l_user_agent: STRING
l_date: DATE_TIME
do
if attached req.http_user_agent as ua then
l_user_agent := ua.as_string_8
else
l_user_agent := "-"
end
create l_date.make_now
io.put_string ("[" + l_date.formatted_out (Date_time_format) + "] %"" + req.request_method + " " + req.request_uri
+ " " + {HTTP_CONSTANTS}.http_version_1_1 + "%" " + res.status_code.out + " " + l_user_agent)
io.put_new_line
execute_next (req, res)
end
feature -- Constants
Date_time_format: STRING = "yyyy/[0]mm/[0]dd [0]hh:[0]mi:[0]ss.ff3"
note
copyright: "2011-2012, Olivier Ligot, Jocelyn Fiat and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

View File

@@ -53,7 +53,7 @@ feature {NONE} -- Initialization
setup_filter
-- Setup `filter'
local
l_logging_filter: LOGGING_FILTER
l_logging_filter: WSF_LOGGING_FILTER
do
create l_logging_filter
filter.set_next (l_logging_filter)

View File

@@ -17,7 +17,7 @@ feature {NONE} -- Initialization
local
h: LIBCURL_HTTP_CLIENT
sess: HTTP_CLIENT_SESSION
resp : HTTP_CLIENT_RESPONSE
resp : detachable HTTP_CLIENT_RESPONSE
l_location : detachable READABLE_STRING_8
body : STRING
do
@@ -39,7 +39,7 @@ feature {NONE} -- Initialization
-- Update the Order
if attached resp.body as l_body then
if resp /= Void and then attached resp.body as l_body then
body := l_body.as_string_8
body.replace_substring_all ("takeAway", "in Shop")
print ("%N Update Order %N")
@@ -47,11 +47,10 @@ feature {NONE} -- Initialization
end
end
update_order ( sess: HTTP_CLIENT_SESSION; uri : detachable READABLE_STRING_8; a_body : STRING) : HTTP_CLIENT_RESPONSE
update_order ( sess: HTTP_CLIENT_SESSION; uri : detachable READABLE_STRING_8; a_body : STRING): detachable HTTP_CLIENT_RESPONSE
local
context : HTTP_CLIENT_REQUEST_CONTEXT
do
create Result.make
if attached uri as l_uri then
sess.set_base_url (l_uri)
create context.make
@@ -74,9 +73,8 @@ feature {NONE} -- Initialization
end
read_order ( sess: HTTP_CLIENT_SESSION; uri : detachable READABLE_STRING_8) : HTTP_CLIENT_RESPONSE
read_order ( sess: HTTP_CLIENT_SESSION; uri : detachable READABLE_STRING_8): detachable HTTP_CLIENT_RESPONSE
do
create Result.make
if attached uri as l_uri then
sess.set_base_url (l_uri)
Result := sess.get ("", Void)

View File

@@ -10,6 +10,9 @@ inherit
ANY
WSF_URI_TEMPLATE_ROUTED_SERVICE
redefine
execute_default
end
WSF_HANDLER_HELPER
@@ -30,10 +33,13 @@ feature {NONE} -- Initialization
setup_router
local
order_handler: ORDER_HANDLER
doc: WSF_ROUTER_SELF_DOCUMENTATION_HANDLER
do
create order_handler
router.handle_with_request_methods ("/order", order_handler, router.methods_POST)
router.handle_with_request_methods ("/order/{orderid}", order_handler, router.methods_GET + router.methods_DELETE + router.methods_PUT)
create doc.make_hidden (router)
router.handle_with_request_methods ("/api/doc", doc, router.methods_GET)
end
feature -- Execution
@@ -54,6 +60,7 @@ feature -- Execution
h.put_content_type_text_plain
l_api_doc := "%NPlease check the API%NURI:/order METHOD: POST%NURI:/order/{orderid} METHOD: GET, PUT, DELETE%N"
l_description := req.request_method + req.request_uri + " is not allowed" + "%N" + l_api_doc
l_description.append ("%NHTML documentation:/api/doc METHOD: GET%N")
h.put_content_length (l_description.count)
h.put_current_date
res.set_status_code ({HTTP_STATUS_CODE}.method_not_allowed)