/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

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