PageRenderTime 90ms CodeModel.GetById 88ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/examples/restbuck_server/src/app/app_request_handler.e

http://github.com/jocelyn/EiffelWebReloaded
Specman e | 69 lines | 59 code | 10 blank | 0 comment | 1 complexity | 291db4ae2a2c966ac6470cf0d31367ae MD5 | raw file
 1note
 2	description : "Objects that ..."
 3	date        : "$Date$"
 4	revision    : "$Revision$"
 5
 6deferred class
 7	APP_REQUEST_HANDLER
 8
 9inherit
10	REST_REQUEST_HANDLER
11
12feature -- Basic operation
13
14	process_error (ctx: REST_REQUEST_CONTEXT; m: STRING; a_format_name: detachable STRING)
15		local
16			rep: REST_RESPONSE
17			s: STRING
18		do
19			create rep.make ("Error")
20			rep.headers.put_status ({HTTP_STATUS_CODE}.expectation_failed)
21			rep.headers.put_content_type_text_plain
22			create s.make_empty
23			s.append_string ("Error: " + m)
24			rep.set_message (s)
25			ctx.output.put_string (rep.string)
26			rep.recycle
27		end
28
29feature {NONE} -- Implementation
30
31	string_hash_table_string_string (ht: HASH_TABLE_ITERATION_CURSOR [STRING_GENERAL, STRING_GENERAL]): STRING_8
32		do
33			from
34				create Result.make (100)
35				ht.start
36			until
37				ht.after
38			loop
39				Result.append_string ("<li><strong>" + ht.key.as_string_8 + "</strong> = " + ht.item.as_string_8 + "</li>%N")
40				ht.forth
41			end
42		end
43
44feature -- Helpers
45
46	format_id (s: detachable STRING): INTEGER
47		do
48			Result := {REST_FORMAT_CONSTANTS}.text
49			if s /= Void then
50				Result := format_constants.format_id (s)
51			end
52		end
53
54	exit_with_code (a_code: INTEGER)
55		do
56			(create {EXCEPTIONS}).die (a_code)
57		end
58
59note
60	copyright: "Copyright (c) 1984-2011, Eiffel Software and others"
61	license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
62	source: "[
63			Eiffel Software
64			5949 Hollister Ave., Goleta, CA 93117 USA
65			Telephone 805-685-1006, Fax 805-685-6869
66			Website http://www.eiffel.com
67			Customer support http://support.eiffel.com
68		]"
69end