diff --git a/draft/library/server/request/rest/src/contrib/doc/rest_api_documentation.e b/draft/library/server/request/rest/src/contrib/doc/rest_api_documentation.e deleted file mode 100644 index 285683f9..00000000 --- a/draft/library/server/request/rest/src/contrib/doc/rest_api_documentation.e +++ /dev/null @@ -1,327 +0,0 @@ -note - description: "Summary description for {REST_API_DOCUMENTATION}." - author: "" - date: "$Date$" - revision: "$Revision$" - -class - REST_API_DOCUMENTATION [C -> REST_REQUEST_HANDLER_CONTEXT] - -inherit - REST_REQUEST_HANDLER [C] - -create - make - -feature {NONE} -- Initialization - - make (a_router: like router; a_base_doc_url: like base_doc_url) - do - router := a_router - base_doc_url := a_base_doc_url - description := "Technical documention for the API" - end - -feature {NONE} -- Access: Implementation - - router: REST_REQUEST_ROUTER [REST_REQUEST_HANDLER [C], C] - - base_doc_url: READABLE_STRING_8 - -feature -- Access - - authentication_required (req: WSF_REQUEST): BOOLEAN - do - end - - resource_value (ctx: C): detachable READABLE_STRING_32 - do - if attached {WSF_STRING} ctx.item ("resource") as s then - Result := s.value - end - end - -feature -- Execution - - execute_application (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) - local - rep: like new_html_page - s: STRING - rq: detachable REST_REQUEST_HANDLER [C] - rq_resource: detachable READABLE_STRING_GENERAL --- l_dft_format_name: detachable STRING - hdl_cursor: like router.new_cursor - do - rep := new_html_page - rep.headers.put_content_type_text_html - create s.make_empty - - if - attached resource_value (ctx) as l_resource - then - from - hdl_cursor := router.new_cursor - until - hdl_cursor.after or rq /= Void - loop - if hdl_cursor.item.resource.same_string_general (l_resource) then - rq := hdl_cursor.item.handler - rq_resource := l_resource - end - hdl_cursor.forth - end - end --- if a_args /= Void and then not a_args.is_empty then --- rq := router.handler_by_path (a_args) --- if rq = Void then --- rq := handler_manager.smart_handler_by_path (a_args) ----- if attached {REST_REQUEST_GROUP_HANDLER} rq as grp then ----- rq := grp.handlers.handler_by_path (a_args) ----- end --- end --- if --- rq /= Void and then --- attached rq.path_information (a_args) as l_info --- then --- l_dft_format_name := l_info.format --- end --- end - - - if rq /= Void and then rq_resource /= Void then - rep.set_big_title ("API: Technical documentation for ["+ rq_resource.as_string_8 +"]") - - s.append_string ("
You will be redirected to " +
+ create html.make
+ redir.set_title ("Bye " + html.html_encoded_string (l_username))
+ redir.set_body ("Bye " + html.html_encoded_string (l_username) + ",
see you soon.
You will be redirected to " + redir.url_location + " in " + redir.delay.out + " second(s) ...
" ) Result := redir diff --git a/examples/tutorial/step_4/hello/src/user_message_handler.e b/examples/tutorial/step_4/hello/src/user_message_handler.e index 616cd337..12a6a0e8 100644 --- a/examples/tutorial/step_4/hello/src/user_message_handler.e +++ b/examples/tutorial/step_4/hello/src/user_message_handler.e @@ -9,20 +9,20 @@ class USER_MESSAGE_HANDLER inherit - WSF_RESPONSE_HANDLER [WSF_URI_TEMPLATE_HANDLER_CONTEXT] + WSF_URI_TEMPLATE_RESPONSE_HANDLER feature -- Access - response (ctx: WSF_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST): WSF_RESPONSE_MESSAGE + response (req: WSF_REQUEST): WSF_RESPONSE_MESSAGE local l_username: READABLE_STRING_32 do - if attached {WSF_STRING} ctx.path_parameter ("user") as u then + if attached {WSF_STRING} req.path_parameter ("user") as u then l_username := html_decoded_string (u.value) if req.is_request_method ("GET") then - Result := user_message_get (l_username, ctx, req) + Result := user_message_get (l_username, req) elseif req.is_request_method ("POST") then - Result := user_message_response_post (l_username, ctx, req) + Result := user_message_response_post (l_username, req) else Result := unsupported_method_response (req) end @@ -46,7 +46,7 @@ feature -- Access end - user_message_get (u: READABLE_STRING_32; ctx: WSF_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST): WSF_HTML_PAGE_RESPONSE + user_message_get (u: READABLE_STRING_32; req: WSF_REQUEST): WSF_HTML_PAGE_RESPONSE local s: STRING_8 do @@ -59,7 +59,7 @@ feature -- Access Result.set_body (s) end - user_message_response_post (u: READABLE_STRING_32; ctx: WSF_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST): WSF_HTML_PAGE_RESPONSE + user_message_response_post (u: READABLE_STRING_32; req: WSF_REQUEST): WSF_HTML_PAGE_RESPONSE local s: STRING_8 do diff --git a/examples/upload_image/src/image_uploader.e b/examples/upload_image/src/image_uploader.e index 0517c6a8..e60602d8 100644 --- a/examples/upload_image/src/image_uploader.e +++ b/examples/upload_image/src/image_uploader.e @@ -10,8 +10,12 @@ class inherit ANY + WSF_ROUTED_SERVICE + WSF_URI_TEMPLATE_ROUTED_SERVICE + WSF_URI_ROUTED_SERVICE + WSF_DEFAULT_SERVICE create @@ -34,14 +38,14 @@ feature {NONE} -- Initialization setup_router -- Setup router local - www: WSF_FILE_SYSTEM_HANDLER [WSF_URI_TEMPLATE_HANDLER_CONTEXT] + www: WSF_FILE_SYSTEM_HANDLER do - router.map_agent ("/upload{?nb}", agent execute_upload) + map_uri_template_agent ("/upload{?nb}", agent execute_upload) create www.make (document_root) www.set_directory_index (<<"index.html">>) www.set_not_found_handler (agent execute_not_found) - router.map_with_request_methods ("{/path}{?query}", www, <<"GET">>) + router.handle_with_request_methods ("", www, router.methods_GET) end feature -- Configuration @@ -59,6 +63,8 @@ feature -- Configuration if Result [Result.count] = Operating_environment.directory_separator then Result := Result.substring (1, Result.count - 1) end + ensure + not Result.ends_with (Operating_environment.directory_separator.out) end files_root: READABLE_STRING_8 @@ -79,13 +85,13 @@ feature -- Execution res.redirect_now_with_content (req.script_url ("/"), "Redirection to " + req.script_url ("/"), "text/html") end - execute_not_found (uri: READABLE_STRING_8; ctx: WSF_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE) + execute_not_found (uri: READABLE_STRING_8; req: WSF_REQUEST; res: WSF_RESPONSE) -- `uri' is not found, redirect to default page do res.redirect_now_with_content (req.script_url ("/"), uri + ": not found.%NRedirection to " + req.script_url ("/"), "text/html") end - execute_upload (ctx: WSF_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE) + execute_upload (req: WSF_REQUEST; res: WSF_RESPONSE) -- Upload page is requested, either GET or POST -- On GET display the web form to upload file, by passing ?nb=5 you can upload 5 images -- On POST display the uploaded files @@ -104,14 +110,14 @@ feature -- Execution page.set_body (l_body) l_body.append ("