From 6344f964fa8f96bd19520c145e3988d268ad4d04 Mon Sep 17 00:00:00 2001 From: jvelilla Date: Sun, 23 Oct 2011 09:05:12 -0300 Subject: [PATCH] Update delete method to hanlde method not allowed. Added method not allowed to request resource handler helper class. Update gitmodules --- .gitmodules | 5 ----- examples/restbucks/src/resource/order_handler.e | 5 +++-- .../src/misc/request_resource_handler_helper.e | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/.gitmodules b/.gitmodules index 5f591df5..8cea3766 100644 --- a/.gitmodules +++ b/.gitmodules @@ -11,8 +11,3 @@ path = ext/ise_library/curl url = http://github.com/EiffelSoftware/mirror-Eiffel-cURL.git [submodule "ext/crypto/eel"] - path = ext/crypto/eel - url = http://github.com/Eiffel-World/eel.git -[submodule "ext/crypto/eapml"] - path = ext/crypto/eapml - url = http://github.com/Eiffel-World/eapml.git diff --git a/examples/restbucks/src/resource/order_handler.e b/examples/restbucks/src/resource/order_handler.e index b2abf8bc..1de6731f 100644 --- a/examples/restbucks/src/resource/order_handler.e +++ b/examples/restbucks/src/resource/order_handler.e @@ -181,7 +181,8 @@ feature -- HTTP Methods -- Here we use DELETE to cancel an order, if that order is in state where -- it can still be canceled. -- 200 if is ok - -- 409 if consumer and service's view of the resouce state is inconsisent + -- 404 Resource not found + -- 405 if consumer and service's view of the resouce state is inconsisent -- 500 if we have an internal server error local id: STRING @@ -194,7 +195,7 @@ feature -- HTTP Methods compute_response_delete (ctx, req, res) else --| FIXME: Here we need to define the Allow methods - handle_resource_conflict_response (orig_path + "%N There is conflict while trying to delete the order, the order could not be deleted in the current state", ctx, req, res) + handle_method_not_allowed_response (orig_path + "%N There is conflict while trying to delete the order, the order could not be deleted in the current state", ctx, req, res) end else handle_resource_not_found_response (orig_path + " not found in this server", ctx, req, res) diff --git a/library/server/request/router/src/misc/request_resource_handler_helper.e b/library/server/request/router/src/misc/request_resource_handler_helper.e index 31bff168..c852085c 100644 --- a/library/server/request/router/src/misc/request_resource_handler_helper.e +++ b/library/server/request/router/src/misc/request_resource_handler_helper.e @@ -239,6 +239,23 @@ feature -- Handle responses res.write_string (a_description) end + handle_method_not_allowed_response (a_description:STRING; ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER ) + local + h : EWF_HEADER + do + create h.make + h.put_status ({HTTP_STATUS_CODE}.method_not_allowed) + if attached ctx.request_content_type (supported_content_types) as l_content_type then + h.put_content_type (l_content_type) + else + h.put_content_type ("*/*") + end + h.put_content_length (a_description.count) + h.put_current_date + res.set_status_code ({HTTP_STATUS_CODE}.method_not_allowed) + res.write_headers_string (h.string) + res.write_string (a_description) + end handle_resource_not_found_response (a_description:STRING; ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) local h : EWF_HEADER