Move "rest" library under "draft/..." since it is more an experiment rather than a real REST library

This commit is contained in:
Jocelyn Fiat
2011-11-23 15:18:35 +01:00
parent 03d9c3785c
commit a3f28e3945
50 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,184 @@
note
description: "Summary description for {HTML_PAGE}."
date: "$Date$"
revision: "$Revision$"
class
HTML_PAGE
inherit
HTML_UTILITIES
create
make
feature {NONE} -- Initialization
make (a_title: like title)
do
create {ARRAYED_LIST [like html_attributes.item]} html_attributes.make (0)
create head.make (a_title)
create {ARRAYED_LIST [like body_attributes.item]} body_attributes.make (0)
create body.make_empty
initialize
end
initialize
-- Initialize
do
create headers.make
end
feature -- Access
headers: WSF_HEADER
feature -- Recycle
recycle
do
html_attributes.wipe_out
headers.recycle
head.recycle
body_attributes.wipe_out
body.wipe_out
internal_header_string := Void
internal_message_string := Void
end
feature -- Access
html_attributes: LIST [TUPLE [name: STRING; value: STRING]]
head: HTML_PAGE_HEAD
body_attributes: LIST [TUPLE [name: STRING; value: STRING]]
body: STRING
feature -- Query
title: detachable STRING
do
Result := head.title
end
add_html_ttribute (a: like html_attributes.item)
do
html_attributes.force (a)
end
add_body_attribute (a: like body_attributes.item)
do
body_attributes.force (a)
end
set_body (s: like body)
-- Set `body' to `s'
do
body := s
end
feature -- Element change
set_title (t: like title)
do
head.title := t
end
feature -- Output
compute
-- Compute the string output
local
s, t: STRING
do
--| HTML beginning
create s.make (128)
s.append_string ("<html")
s.append_string (attributes_to_string (html_attributes))
s.append_string (">%N")
--| Head
head.compute --| Be sure to have a fresh string
t := head.string
if not t.is_empty then
s.append_string (t)
s.append_character ('%N')
end
--| Body
s.append_string ("<body")
s.append_string (attributes_to_string (body_attributes))
s.append_string (">%N")
s.append_string (body)
s.append_string ("</body>")
--| End
s.append_string ("</html>")
--| Http headers
headers.put_content_length (s.count)
internal_header_string := headers.string
internal_message_string := s
end
header_string: STRING
local
o: like internal_header_string
do
o := internal_header_string
if o = Void then
compute
o := internal_header_string
if o = Void then
check output_computed: False end
create o.make_empty
end
end
Result := o
end
message_string: STRING
local
o: like internal_message_string
do
o := internal_message_string
if o = Void then
compute
o := internal_message_string
if o = Void then
check output_computed: False end
create o.make_empty
end
end
Result := o
end
send (buf: WSF_RESPONSE)
do
buf.set_status_code (200)
buf.write_headers_string (header_string)
buf.write_string (message_string)
end
feature {NONE} -- Implementation: output
internal_header_string: detachable like header_string
internal_message_string: detachable like message_string
invariant
header_attached: headers /= Void
;note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,111 @@
note
description: "Summary description for {HTML_PAGE_HEAD}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
HTML_PAGE_HEAD
inherit
HTML_UTILITIES
create
make
feature {NONE} -- Initialization
make (a_title: like title)
do
initialize
title := a_title
end
initialize
do
create text.make_empty
create {ARRAYED_LIST [like attributes.item]} attributes.make (0)
end
feature -- Recycle
recycle
do
attributes.wipe_out
title := Void
text.wipe_out
internal_string := Void
end
feature -- Access
attributes: LIST [TUPLE [name: STRING; value: STRING]]
title: detachable STRING assign set_title
text: STRING
feature -- Element change
set_title (t: like title)
do
title := t
end
feature -- Output
compute
-- Compute the string output
local
s: STRING
do
create s.make_empty
if attached title as t then
s.append_string ("<title>" + t + "</title>%N")
end
if text.count > 0 then
s.append_string (text)
s.append_character ('%N')
end
if s.count > 0 then
internal_string := "<head" + attributes_to_string (attributes) + ">%N" + s + "</head>"
else
internal_string := s
end
end
string: STRING
--
local
o: like internal_string
do
o := internal_string
if o = Void then
compute
o := internal_string
if o = Void then
check output_computed: False end
create o.make_empty
end
end
Result := o
end
feature {NONE} -- Implementation: output
internal_string: detachable like string
invariant
text_attached: text /= Void
note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,90 @@
note
description: "Summary description for {HTML_UTILITIES}."
date: "$Date$"
revision: "$Revision$"
class
HTML_UTILITIES
feature -- Encoding
html_special_chars_encoded_string (s: STRING): STRING
local
c: CHARACTER
i,n: INTEGER
do
from
i := 1
n := s.count
create Result.make (n + 10)
until
i > n
loop
c := s[i]
inspect c
when '&' then
Result.append_string ("&amp;")
when '%"' then
Result.append_string ("&quot;")
when '%'' then
Result.append_string ("&#039;")
when '<' then
Result.append_string ("&lt;")
when '>' then
Result.append_string ("&gt;")
else
Result.extend (c)
end
i := i + 1
end
end
feature -- Helpers
strings_to_string (lst: LIST [STRING]; sep: STRING): STRING
do
create Result.make_empty
if lst.count > 0 then
from
lst.start
until
lst.after
loop
Result.append_string (lst.item)
Result.append_string (sep)
lst.forth
end
end
end
attributes_to_string (atts: LIST [TUPLE [name: STRING; value: STRING]]): STRING
do
create Result.make_empty
if atts.count > 0 then
from
atts.start
until
atts.after
loop
Result.append_character (' ')
Result.append_string (atts.item.name)
Result.append_character ('=')
Result.append_character ('%"')
Result.append_string (html_special_chars_encoded_string (atts.item.value))
Result.append_character ('%"')
atts.forth
end
end
end
note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,321 @@
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
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 {WSF_STRING} ctx.path_parameter ("resource") as l_resource_value and then
attached l_resource_value.string 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 ("<div class=%"api%">")
s.append_string ("<h2 class=%"api-name%" >")
s.append_string ("<a href=%"" + base_doc_url + "%">.. Show all features ..</a>")
s.append_string ("</h2></div>%N")
process_request_handler_doc (rq, rq_resource.as_string_8, s, ctx, req, res, Void)
else
rep.set_big_title ("API: Technical documentation")
from
hdl_cursor := router.new_cursor
until
hdl_cursor.after
loop
if attached hdl_cursor.item as l_item then
rq := l_item.handler
rep.add_shortcut (l_item.resource)
s.append ("<a name=%"" + rep.last_added_shortcut + "%"/>")
process_request_handler_doc (rq, l_item.resource, s, ctx, req, res, Void)
hdl_cursor.forth
end
end
end
rep.set_body (s)
rep.send (res)
rep.recycle
end
process_request_handler_doc (rq: REST_REQUEST_HANDLER [C]; a_resource: STRING; buf: STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE; a_dft_format: detachable STRING)
local
l_dft_format_name: detachable STRING
s: STRING
l_uri_tpl: URI_TEMPLATE
do
s := buf
if a_dft_format /= Void then
if rq.supported_format_names.has (a_dft_format) then
l_dft_format_name := a_dft_format
end
end
s.append_string ("<div class=%"api%">")
s.append_string ("<h2 class=%"api-name%" ><a href=%""+ url (req, base_doc_url, a_resource, False) +"%">"+ a_resource +"</a></h2>")
s.append_string ("<div class=%"inner%">")
-- if rq.hidden (req) then
-- s.append_string ("<div class=%"api-description%">This feature is hidden</div>%N")
-- else
if attached rq.description as desc then
s.append_string ("<div class=%"api-description%">" + desc + "</div>")
end
-- if attached {REST_REQUEST_GROUP_HANDLER} rq as grp then
-- s.append_string ("<div class=%"api-format%">Handler: <strong>")
-- if attached grp.handlers.new_cursor as l_handlers_cursor then
-- from
-- until
-- l_handlers_cursor.after
-- loop
-- s.append_string (" ")
-- s.append_string ("<a class=%"api-handler%" href=%"")
-- s.append_string (url (ctx, l_handlers_cursor.item.path, False))
-- s.append_string ("%">"+ l_handlers_cursor.item.path +"</a>")
-- l_handlers_cursor.forth
-- end
-- end
-- s.append_string ("</strong></div>")
-- end
if attached rq.supported_format_names as l_formats and then not l_formats.is_empty then
s.append_string ("<div class=%"api-format%">Supported formats: <strong>")
if attached l_formats.new_cursor as l_formats_cursor then
from
until
l_formats_cursor.after
loop
s.append_string (" ")
s.append_string ("<a class=%"api-name api-format")
if l_formats_cursor.item ~ l_dft_format_name then
s.append_string (" selected")
end
s.append_string ("%" href=%"" + url (req, base_doc_url, a_resource, False) + "." + l_formats_cursor.item + "%">"+ l_formats_cursor.item +"</a>")
l_formats_cursor.forth
end
end
s.append_string ("</strong></div>")
end
if attached rq.supported_request_method_names as l_methods and then not l_methods.is_empty then
s.append_string ("<div class=%"api-method%">Supported request methods: <strong>")
if attached l_methods.new_cursor as l_methods_cursor then
from
until
l_methods_cursor.after
loop
s.append_string (" ")
s.append_string (l_methods_cursor.item)
l_methods_cursor.forth
end
end
s.append_string ("</strong></div>")
end
s.append_string ("<div class=%"api-auth%">Authentication required: <strong>" + rq.authentication_required (req).out + "</strong></div>")
if attached {REST_REQUEST_URI_TEMPLATE_ROUTER_I [REST_REQUEST_HANDLER [REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT], REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT]} router as l_uri_template_router then
create l_uri_tpl.make (a_resource)
if attached l_uri_tpl.query_variable_names as l_query_variable_names and then not l_query_variable_names.is_empty then
s.append_string ("<div class=%"api-uri-template%">Query parameters: ")
-- s.append_string (rq.path)
from
l_query_variable_names.start
until
l_query_variable_names.after
loop
if l_query_variable_names.isfirst then
s.append_string ("?")
else
s.append_string ("&")
end
if attached l_query_variable_names.item as l_query_param then
s.append_string ("<strong>" + l_query_param + "</strong>")
s.append_string ("=<em>" + l_query_param + "</em>")
end
l_query_variable_names.forth
end
s.append_string ("</div>%N")
end
if attached l_uri_tpl.path_variable_names as l_path_variable_names and then not l_path_variable_names.is_empty then
s.append_string ("<div class=%"api-uri-template%">Path Segment parameters: ")
-- s.append_string (rq.path)
from
l_path_variable_names.start
until
l_path_variable_names.after
loop
if attached l_path_variable_names.item as l_seg_param then
s.append_string ("<em>{" + l_seg_param + "}</em>")
end
l_path_variable_names.forth
end
s.append_string ("</div>%N")
end
end
-- if attached rq._parameters as l_uri_params and then not l_uri_params.is_empty then
-- s.append_string ("<div class=%"api-uri-template%">URI Template: ")
-- s.append_string (rq.path)
-- if attached l_uri_params.new_cursor as l_uri_params_cursor then
-- from
-- until
-- l_uri_params_cursor.after
-- loop
-- if attached l_uri_params_cursor.item as l_uri_param then
-- s.append_string ("/<strong>" + l_uri_param.name + "</strong>")
-- s.append_string ("/<em>{" + l_uri_param.name + "}</em>")
-- end
-- l_uri_params_cursor.forth
-- end
-- end
-- s.append_string ("</div>%N")
-- end
-- if attached rq.parameters as l_params and then not l_params.is_empty then
-- s.append_string ("<div class=%"api-params%">Parameters: ")
-- --| show form only if we have a default format
-- if l_dft_format_name = Void then
-- s.append_string ("<span class=%"note%">to test the parameter(s), please first select a supported format.</span>%N")
-- else
-- if rq.method_post_supported then
-- s.append_string ("<form id=%""+ rq.path +"%" method=%"POST%" action=%"" + ctx.script_url (rq.path) + "." + l_dft_format_name + "%">%N")
-- else
-- s.append_string ("<form id=%""+ rq.path +"%" method=%"GET%" action=%"" + ctx.script_url (rq.path) + "." + l_dft_format_name + "%">%N")
-- end
-- end
-- s.append_string ("<ul>")
-- if attached l_params.new_cursor as l_params_cursor then
-- from
-- until
-- l_params_cursor.after
-- loop
-- if attached l_params_cursor.item as l_param then
-- s.append_string ("<li><strong>" + l_param.name + "</strong>")
-- if l_param.optional then
-- s.append_string (" <em>(Optional)</em>")
-- end
-- if attached l_param.description as l_param_desc then
-- s.append_string (": <em>" + l_param_desc + "</em>")
-- end
-- if l_dft_format_name /= Void then
-- s.append (" <input name=%"" + l_param.name + "%" type=%"text%" />")
-- end
-- s.append_string ("</li>")
-- end
-- l_params_cursor.forth
-- end
-- end
-- if l_dft_format_name /= Void then
-- s.append_string ("<input type=%"submit%" value=%"Test "+ rq.path + "." + l_dft_format_name + "%"/>")
-- s.append_string ("</form>")
-- end
-- s.append_string ("</ul></div>")
-- else
-- if l_dft_format_name /= Void then
-- s.append_string ("<a class=%"api-name%" href=%"" + ctx.script_url (a_resource + "." + l_dft_format_name) + "%">Test "+ a_resource + "." + l_dft_format_name + "</a>")
-- else
-- s.append_string ("<a class=%"api-name%" href=%"" + ctx.script_url (a_resource) + "%">Test "+ a_resource +"</a>")
-- end
-- end
s.append_string ("</div>%N")
-- end
s.append_string ("</div>%N") -- inner
end
feature -- Access
new_html_page: REST_API_DOCUMENTATION_HTML_PAGE
do
create Result.make ("API Documentation")
end
note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,124 @@
note
description: "Summary description for {REST_API_DOCUMENTATION_HTML_PAGE}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
REST_API_DOCUMENTATION_HTML_PAGE
inherit
HTML_PAGE
redefine
head,
initialize,
recycle,
compute
end
create
make
feature {NONE} -- Initialization
initialize
do
Precursor
create {LINKED_LIST [like shortcuts.item]} shortcuts.make
end
feature -- Recyle
recycle
do
Precursor
shortcuts.wipe_out
end
feature -- Access
head: REST_API_DOCUMENTATION_HTML_PAGE_HEAD
big_title: detachable STRING
shortcuts: LIST [TUPLE [name: STRING; anchor: STRING]]
add_shortcut (s: STRING)
local
t: STRING
do
t := s.string
t.replace_substring_all ("/", "-")
shortcuts.force ([s,t])
end
last_added_shortcut: STRING
do
if shortcuts.count > 0 and then attached shortcuts.last as sht then
Result := sht.anchor
else
create Result.make_empty
end
end
shortcuts_to_html: detachable STRING
do
if not shortcuts.is_empty then
from
create Result.make_from_string ("<strong>Shortcuts:</strong> | ")
shortcuts.start
until
shortcuts.after
loop
Result.append_string ("<a href=%"#"+ shortcuts.item.anchor +"%">"+ shortcuts.item.name +"</a> | ")
shortcuts.forth
end
end
end
feature -- Element change
set_big_title (t: like big_title)
do
big_title := t
end
feature -- Basic operation
compute
local
l_old_body: STRING
sh, bt: detachable STRING
do
sh := shortcuts_to_html
bt := big_title
if sh /= Void or bt /= Void then
l_old_body := body
if bt /= Void then
bt := "<h1>" + bt + "</h2>%N"
if sh /= Void then
body := bt + sh + l_old_body
else
body := bt + l_old_body
end
elseif sh /= Void then
body := sh + l_old_body
end
Precursor
body := l_old_body
else
Precursor
end
end
;note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,75 @@
note
description: "Summary description for {REST_API_DOCUMENTATION_HTML_PAGE_HEAD}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
REST_API_DOCUMENTATION_HTML_PAGE_HEAD
inherit
HTML_PAGE_HEAD
redefine
initialize,
compute
end
create
make
feature {NONE} -- Initialization
initialize
do
Precursor
style := "[
body {margin: 0px;}
a { text-decoration: none; }
h1 { padding: 10px; border: solid 2px #000; background-color: #009; color: #fff;}
div.api { padding: 5px; margin-bottom: 10px;}
div.api .api-description { padding: 5px 5px 5px 0px; font-style: italic; color: #090;}
div.api div.inner { padding-left: 40px;}
div.api h2>a { color: #009; text-decoration: none;}
div.api a.api-format { color: #009; text-decoration: none;}
div.api a.api-format.selected { padding: 0 4px 0 4px; color: #009; text-decoration: none; border: solid 1px #99c; background-color: #eeeeff;}
div.api>h2 { margin: 2px; padding: 2px 2px 2px 10px; display: inline-block; border: dotted 1px #cce; width: 100%; color: #009; background-color: #E7F3F8; text-decoration: none; font-weight: bold; font-size: 120%;}
div.api span.note { font-style: italic;}
]"
end
feature {REST_API_DOCUMENTATION_HTML_PAGE} -- Access
style: STRING
feature -- Output
compute
-- Compute the string output
local
s: detachable STRING
p: INTEGER
do
Precursor
s := internal_string
if s /= Void then
p := s.substring_index ("</head>", 1)
if p > 0 then
s.insert_string ("<style>%N" + style + "%N</style>%N", p)
else
s.append_string ("<style>%N" + style + "%N</style>%N")
end
end
end
note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,47 @@
note
description: "Summary description for REST_REQUEST_GROUP_HANDLER."
author: ""
date: "$Date$"
revision: "$Revision$"
class
REST_REQUEST_GROUP_HANDLER [H -> REST_REQUEST_HANDLER [C], C -> REST_REQUEST_HANDLER_CONTEXT]
inherit
REQUEST_ROUTING_HANDLER [H, C]
redefine
execute
end
REST_REQUEST_HANDLER [C]
redefine
execute
select
execute_application
end
create
make
feature -- status
authentication_required: BOOLEAN
feature -- Execution
execute (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
do
Precursor {REST_REQUEST_HANDLER} (ctx, req, res)
end
;note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,156 @@
note
description: "Summary description for {REST_RESPONSE}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
REST_RESPONSE
create
make
feature {NONE} -- Initialization
make (a_api: like api)
do
api := a_api
initialize
end
initialize
do
create headers.make
end
feature -- Recycle
recycle
do
headers.recycle
end
feature -- Access
headers: WSF_HEADER
api: STRING
-- Associated api query string.
message: detachable STRING_8
-- Associated message to send with the response.
feature -- Element change
set_message (m: like message)
-- Set `message' to `m'
do
message := m
end
append_message (m: attached like message)
-- Append message `m' to current `message' value
-- create `message' is Void
require
m_not_empty: m /= Void and then not m.is_empty
do
if attached message as msg then
msg.append (m)
else
set_message (m.string)
end
end
append_message_file_content (fn: STRING)
-- Append file content from `fn' to the response
--| To use with care.
--| You should avoid using this for big or binary content ...
local
f: RAW_FILE
do
create f.make (fn)
if f.exists and then f.is_readable then
f.open_read
from
until
f.exhausted
loop
f.read_stream (1024)
append_message (f.last_string)
end
f.close
end
end
feature -- Output
update_content_length (a_overwrite: BOOLEAN)
-- Update content length
-- if the header already exists it won't change it,
-- unless `a_overwrite' is set to True
local
hds: like headers
len: INTEGER
do
hds := headers
if a_overwrite or else not hds.has_content_length then
if attached message as m then
len := m.count
-- if {PLATFORM}.is_windows then
-- len := len + m.occurrences ('%N') --| FIXME: find better solution
-- end
else
len := 0
end
hds.put_content_length (len)
end
end
compute
-- Compute the string output
do
update_content_length (False)
internal_headers_string := headers.string
end
headers_string: STRING
local
o: like internal_headers_string
do
o := internal_headers_string
if o = Void then
compute
o := internal_headers_string
if o = Void then
check output_computed: False end
create o.make_empty
end
end
Result := o
end
send (res: WSF_RESPONSE)
do
compute
res.set_status_code (200)
res.write_headers_string (headers_string)
if attached message as m then
res.write_string (m)
end
end
feature {NONE} -- Implementation: output
internal_headers_string: detachable like headers_string
;note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,52 @@
note
description: "Summary description for REST_REQUEST_AGENT_HANDLER."
author: ""
date: "$Date$"
revision: "$Revision$"
class
REST_REQUEST_AGENT_HANDLER [C -> REST_REQUEST_HANDLER_CONTEXT]
inherit
REQUEST_AGENT_HANDLER [C]
rename
execute as execute_application
end
REST_REQUEST_HANDLER [C]
select
execute
end
create
make
feature -- status
authentication_required (req: WSF_REQUEST): BOOLEAN
do
Result := internal_authentication_required
end
feature -- Element change
set_authentication_required (b: like authentication_required)
do
internal_authentication_required := b
end
feature {NONE} -- Implementation
internal_authentication_required: BOOLEAN
;note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,339 @@
note
description: "Summary description for {REST_REQUEST_HANDLER}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
REST_REQUEST_HANDLER [C -> REST_REQUEST_HANDLER_CONTEXT]
inherit
REQUEST_HANDLER [C]
redefine
execute
end
feature -- Access
authentication_required (req: WSF_REQUEST): BOOLEAN
-- Is authentication required
-- might depend on the request environment
-- or the associated resources
deferred
end
description: detachable STRING
-- Optional description
feature -- Element change
set_description (s: like description)
-- Set `description' to `s'
do
description := s
end
feature -- Execution
execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute request handler
local
rescued: BOOLEAN
do
if not rescued then
if request_method_name_supported (req.request_method) then
if authentication_required (req) and then not authenticated (ctx) then
execute_unauthorized (ctx, req, res)
else
pre_execute (ctx, req, res)
execute_application (ctx, req, res)
post_execute (ctx, req, res)
end
else
execute_request_method_not_allowed (req, res, supported_request_method_names)
end
else
rescue_execute (ctx, req, res)
end
rescue
rescued := True
retry
end
execute_application (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
deferred
end
pre_execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
end
post_execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
end
rescue_execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
post_execute (ctx, req, res)
end
execute_unauthorized (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
res.set_status_code ({HTTP_STATUS_CODE}.unauthorized)
res.write_header ({HTTP_STATUS_CODE}.unauthorized, Void)
res.write_string ("Unauthorized")
end
feature -- Auth
authenticated (ctx: C): BOOLEAN
-- Is authenticated?
do
--| To redefine if needed
end
feature {NONE} -- Implementation
supported_formats: INTEGER
-- Support request format result such as json, xml, ...
feature {NONE} -- Status report
format_id_supported (a_id: INTEGER): BOOLEAN
do
Result := (supported_formats & a_id) = a_id
end
format_name_supported (n: STRING): BOOLEAN
-- Is format `n' supported?
do
Result := format_id_supported (format_constants.format_id (n))
end
format_constants: HTTP_FORMAT_CONSTANTS
once
create Result
end
feature -- Status report
supported_format_names: LIST [STRING]
-- Supported format names ...
do
create {LINKED_LIST [STRING]} Result.make
if format_json_supported then
Result.extend (format_constants.json_name)
end
if format_xml_supported then
Result.extend (format_constants.xml_name)
end
if format_text_supported then
Result.extend (format_constants.text_name)
end
if format_html_supported then
Result.extend (format_constants.html_name)
end
if format_rss_supported then
Result.extend (format_constants.rss_name)
end
if format_atom_supported then
Result.extend (format_constants.atom_name)
end
end
format_json_supported: BOOLEAN
do
Result := format_id_supported ({HTTP_FORMAT_CONSTANTS}.json)
end
format_xml_supported: BOOLEAN
do
Result := format_id_supported ({HTTP_FORMAT_CONSTANTS}.xml)
end
format_text_supported: BOOLEAN
do
Result := format_id_supported ({HTTP_FORMAT_CONSTANTS}.text)
end
format_html_supported: BOOLEAN
do
Result := format_id_supported ({HTTP_FORMAT_CONSTANTS}.html)
end
format_rss_supported: BOOLEAN
do
Result := format_id_supported ({HTTP_FORMAT_CONSTANTS}.rss)
end
format_atom_supported: BOOLEAN
do
Result := format_id_supported ({HTTP_FORMAT_CONSTANTS}.atom)
end
feature -- Element change: formats
reset_supported_formats
do
supported_formats := 0
end
enable_format_json
do
enable_format ({HTTP_FORMAT_CONSTANTS}.json)
end
enable_format_xml
do
enable_format ({HTTP_FORMAT_CONSTANTS}.xml)
end
enable_format_text
do
enable_format ({HTTP_FORMAT_CONSTANTS}.text)
end
enable_format_html
do
enable_format ({HTTP_FORMAT_CONSTANTS}.html)
end
enable_format (f: INTEGER)
do
supported_formats := supported_formats | f
end
feature {NONE} -- Implementation
supported_request_methods: INTEGER
-- Support request method such as GET, POST, ...
feature {NONE} -- Status report
request_method_id_supported (a_id: INTEGER): BOOLEAN
do
Result := (supported_request_methods & a_id) = a_id
end
request_method_name_supported (n: STRING): BOOLEAN
-- Is request method `n' supported?
do
Result := request_method_id_supported (request_method_constants.method_id (n))
end
request_method_constants: HTTP_REQUEST_METHOD_CONSTANTS
once
create Result
end
feature -- Status report
supported_request_method_names: LIST [STRING]
-- Support request method such as GET, POST, ...
do
create {LINKED_LIST [STRING]} Result.make
if method_get_supported then
Result.extend (request_method_constants.method_get)
end
if method_post_supported then
Result.extend (request_method_constants.method_post)
end
if method_put_supported then
Result.extend (request_method_constants.method_put)
end
if method_patch_supported then
Result.extend (request_method_constants.method_patch)
end
if method_delete_supported then
Result.extend (request_method_constants.method_delete)
end
if method_head_supported then
Result.extend (request_method_constants.method_head)
end
end
method_get_supported: BOOLEAN
do
Result := request_method_id_supported ({HTTP_REQUEST_METHOD_CONSTANTS}.get)
end
method_post_supported: BOOLEAN
do
Result := request_method_id_supported ({HTTP_REQUEST_METHOD_CONSTANTS}.post)
end
method_put_supported: BOOLEAN
do
Result := request_method_id_supported ({HTTP_REQUEST_METHOD_CONSTANTS}.put)
end
method_patch_supported: BOOLEAN
do
Result := request_method_id_supported ({HTTP_REQUEST_METHOD_CONSTANTS}.patch)
end
method_delete_supported: BOOLEAN
do
Result := request_method_id_supported ({HTTP_REQUEST_METHOD_CONSTANTS}.delete)
end
method_head_supported: BOOLEAN
do
Result := request_method_id_supported ({HTTP_REQUEST_METHOD_CONSTANTS}.head)
end
feature -- Element change: request methods
reset_supported_request_methods
do
supported_request_methods := 0
end
enable_request_method_get
do
enable_request_method ({HTTP_REQUEST_METHOD_CONSTANTS}.get)
end
enable_request_method_post
do
enable_request_method ({HTTP_REQUEST_METHOD_CONSTANTS}.post)
end
enable_request_method_put
do
enable_request_method ({HTTP_REQUEST_METHOD_CONSTANTS}.put)
end
enable_request_method_patch
do
enable_request_method ({HTTP_REQUEST_METHOD_CONSTANTS}.patch)
end
enable_request_method_delete
do
enable_request_method ({HTTP_REQUEST_METHOD_CONSTANTS}.delete)
end
enable_request_method_head
do
enable_request_method ({HTTP_REQUEST_METHOD_CONSTANTS}.head)
end
enable_request_method (m: INTEGER)
do
supported_request_methods := supported_request_methods | m
end
note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,67 @@
note
description: "Summary description for {REST_REQUEST_HANDLER_CONTEXT}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
REST_REQUEST_HANDLER_CONTEXT
inherit
REQUEST_HANDLER_CONTEXT
feature -- Status report
script_absolute_url (a_path: STRING): STRING
-- Absolute Url for the script if any, extended by `a_path'
do
Result := request.absolute_script_url (a_path)
end
script_url (a_path: STRING): STRING
-- Url relative to script name if any, extended by `a_path'
require
a_path_attached: a_path /= Void
do
Result := request.script_url (a_path)
end
url (args: detachable STRING; abs: BOOLEAN): STRING
-- Associated url based on `path' and `args'
-- if `abs' then return absolute url
local
s,t: detachable STRING
do
s := args
if s /= Void and then s.count > 0 then
create t.make_from_string (path)
if s[1] /= '/' then
t.append_character ('/')
t.append (s)
else
t.append (s)
end
s := t
else
s := path
end
if abs then
Result := script_absolute_url (s)
else
Result := script_url (s)
end
ensure
result_attached: Result /= Void
end
note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,23 @@
note
description: "Summary description for {REST_REQUEST_ROUTER}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
REST_REQUEST_ROUTER [H -> REST_REQUEST_HANDLER [C], C -> REST_REQUEST_HANDLER_CONTEXT]
inherit
REQUEST_ROUTER [H, C]
;note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,23 @@
note
description: "Summary description for {DEFAULT_REST_SERVICE}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
REST_SERVICE
inherit
REST_SERVICE_I [REST_REQUEST_HANDLER [REST_REQUEST_HANDLER_CONTEXT], REST_REQUEST_HANDLER_CONTEXT]
note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,31 @@
note
description: "Summary description for {REST_SERVICE}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
REST_SERVICE_I [H -> REST_REQUEST_HANDLER [C], C -> REST_REQUEST_HANDLER_CONTEXT]
inherit
ROUTED_SERVICE_I [H, C]
redefine
router
end
feature -- Setup
router: REST_REQUEST_ROUTER [H, C]
-- Request router
;note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,24 @@
note
description: "Summary description for {DEFAULT_REST_REQUEST_URI_HANDLER}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
REST_REQUEST_URI_HANDLER
inherit
REST_REQUEST_HANDLER [REST_REQUEST_URI_HANDLER_CONTEXT]
;note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,28 @@
note
description: "Summary description for {REQUEST_URI_HANDLER_CONTEXT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
REST_REQUEST_URI_HANDLER_CONTEXT
inherit
REQUEST_URI_HANDLER_CONTEXT
REST_REQUEST_HANDLER_CONTEXT
create
make
note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,40 @@
note
description: "Summary description for {DEFAULT_REST_REQUEST_URI_ROUTER}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
REST_REQUEST_URI_ROUTER
inherit
REST_REQUEST_URI_ROUTER_I [REST_REQUEST_HANDLER [REST_REQUEST_URI_HANDLER_CONTEXT], REST_REQUEST_URI_HANDLER_CONTEXT]
redefine
map_agent_with_request_methods
end
create
make
feature -- Mapping
map_agent_with_request_methods (a_id: READABLE_STRING_8; a_action: PROCEDURE [ANY, TUPLE [ctx: REST_REQUEST_URI_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE]];
rqst_methods: detachable ARRAY [READABLE_STRING_8])
local
h: REST_REQUEST_AGENT_HANDLER [REST_REQUEST_URI_HANDLER_CONTEXT]
do
create h.make (a_action)
map_with_request_methods (a_id, h, rqst_methods)
end
note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,36 @@
note
description: "Summary description for {REST_REQUEST_URI_ROUTER}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
REST_REQUEST_URI_ROUTER_I [H -> REST_REQUEST_HANDLER [C], C -> REST_REQUEST_URI_HANDLER_CONTEXT create make end]
inherit
REQUEST_URI_ROUTER_I [H, C]
REST_REQUEST_ROUTER [H, C]
create
make
feature -- Mapping
-- map_agent_with_request_methods (a_id: READABLE_STRING_8; a_action: like {REST_REQUEST_AGENT_HANDLER}.action; rqst_methods: detachable ARRAY [READABLE_STRING_8])
-- do
-- Precursor (a_id, a_action, rqst_methods)
-- end
note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,33 @@
note
description: "Summary description for {DEFAULT_REST_REQUEST_URI_ROUTING_HANDLER}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
REST_REQUEST_URI_ROUTING_HANDLER
inherit
REST_REQUEST_URI_ROUTING_HANDLER_I [REST_REQUEST_HANDLER [REST_REQUEST_URI_HANDLER_CONTEXT], REST_REQUEST_URI_HANDLER_CONTEXT]
redefine
router
end
create
make
feature {NONE} -- Routing
router: REST_REQUEST_URI_ROUTER
;note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,64 @@
note
description: "Summary description for {REQUEST_ROUTING_HANDLER}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
REST_REQUEST_URI_ROUTING_HANDLER_I [H -> REST_REQUEST_HANDLER [C],
C -> REST_REQUEST_URI_HANDLER_CONTEXT create make end]
inherit
REQUEST_URI_ROUTING_HANDLER_I [H, C]
redefine
router,
execute
end
REST_REQUEST_HANDLER [C]
undefine
execute
end
create
make
feature -- Status report
authentication_required (req: WSF_REQUEST): BOOLEAN
do
Result := internal_authentication_required
end
feature {NONE} -- Implementation
internal_authentication_required: BOOLEAN
feature -- Execution
execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
Precursor {REQUEST_URI_ROUTING_HANDLER_I} (ctx, req, res)
end
execute_application (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
check should_not_occur: False end
end
feature {NONE} -- Routing
router: REST_REQUEST_URI_ROUTER_I [H, C]
;note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,30 @@
note
description: "Summary description for {DEFAULT_REST_URI_SERVICE}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
REST_URI_SERVICE
inherit
REST_SERVICE_I [REST_REQUEST_HANDLER [REST_REQUEST_URI_HANDLER_CONTEXT], REST_REQUEST_URI_HANDLER_CONTEXT]
redefine
router
end
feature -- Router
router: REST_REQUEST_URI_ROUTER
;note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,24 @@
note
description: "Summary description for {DEFAULT_REST_REQUEST_URI_TEMPLATE_HANDLER}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
REST_REQUEST_URI_TEMPLATE_HANDLER
inherit
REST_REQUEST_HANDLER [REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT]
;note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,28 @@
note
description: "Summary description for {REQUEST_URI_TEMPLATE_HANDLER_CONTEXT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT
inherit
REQUEST_URI_TEMPLATE_HANDLER_CONTEXT
REST_REQUEST_HANDLER_CONTEXT
create
make
note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,40 @@
note
description: "Summary description for {DEFAULT_REST_REQUEST_URI_TEMPLATE_ROUTER}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
REST_REQUEST_URI_TEMPLATE_ROUTER
inherit
REST_REQUEST_URI_TEMPLATE_ROUTER_I [REST_REQUEST_HANDLER [REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT], REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT]
redefine
map_agent_with_request_methods
end
create
make
feature -- Mapping
map_agent_with_request_methods (a_id: READABLE_STRING_8; a_action: PROCEDURE [ANY, TUPLE [ctx: REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE]];
rqst_methods: detachable ARRAY [READABLE_STRING_8])
local
h: REST_REQUEST_AGENT_HANDLER [REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT]
do
create h.make (a_action)
map_with_request_methods (a_id, h, rqst_methods)
end
note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,28 @@
note
description: "Summary description for {REST_REQUEST_URI_TEMPLATE_ROUTER}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
REST_REQUEST_URI_TEMPLATE_ROUTER_I [H -> REST_REQUEST_HANDLER [C], C -> REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT create make end]
inherit
REQUEST_URI_TEMPLATE_ROUTER_I [H, C]
REST_REQUEST_ROUTER [H, C]
create
make
note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,33 @@
note
description: "Summary description for {DEFAULT_REST_REQUEST_URI_TEMPLATE_ROUTING_HANDLER}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
REST_REQUEST_URI_TEMPLATE_ROUTING_HANDLER
inherit
REST_REQUEST_URI_TEMPLATE_ROUTING_HANDLER_I [REST_REQUEST_HANDLER [REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT], REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT]
redefine
router
end
create
make
feature {NONE} -- Routing
router: REST_REQUEST_URI_TEMPLATE_ROUTER
;note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,65 @@
note
description: "Summary description for {REQUEST_ROUTING_HANDLER}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
REST_REQUEST_URI_TEMPLATE_ROUTING_HANDLER_I [H -> REST_REQUEST_HANDLER [C],
C -> REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT create make end]
inherit
REQUEST_URI_TEMPLATE_ROUTING_HANDLER_I [H, C]
redefine
router,
execute
end
REST_REQUEST_HANDLER [C]
undefine
execute
end
create
make
feature -- Status report
authentication_required (req: WSF_REQUEST): BOOLEAN
do
Result := internal_authentication_required
end
feature {NONE} -- Implementation
internal_authentication_required: BOOLEAN
feature -- Execution
execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
pre_execute (ctx, req, res)
Precursor {REQUEST_URI_TEMPLATE_ROUTING_HANDLER_I} (ctx, req, res)
post_execute (ctx, req, res)
end
execute_application (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
check should_not_occur: False end
end
feature {NONE} -- Routing
router: REST_REQUEST_URI_TEMPLATE_ROUTER_I [H, C]
;note
copyright: "Copyright (c) 1984-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

View File

@@ -0,0 +1,30 @@
note
description: "Summary description for {DEFAULT_URI_TEMPLATE_REST_SERVICE}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
REST_URI_TEMPLATE_SERVICE
inherit
REST_SERVICE_I [REST_REQUEST_HANDLER [REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT], REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT]
redefine
router
end
feature -- Router
router: REST_REQUEST_URI_TEMPLATE_ROUTER
;note
copyright: "Copyright (c) 1984-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