/src/yolk-handlers.adb

http://github.com/ThomasLocke/yolk · Ada · 91 lines · 50 code · 17 blank · 24 comment · 1 complexity · edd673f1c2058a465c60e6432fc9fecd MD5 · raw file

  1. -------------------------------------------------------------------------------
  2. -- --
  3. -- Copyright (C) 2010-, Thomas ¸cke --
  4. -- --
  5. -- This library is free software; you can redistribute it and/or modify --
  6. -- it under terms of the GNU General Public License as published by the --
  7. -- Free Software Foundation; either version 3, or (at your option) any --
  8. -- later version. This library is distributed in the hope that it will be --
  9. -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
  10. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
  11. -- --
  12. -- As a special exception under Section 7 of GPL version 3, you are --
  13. -- granted additional permissions described in the GCC Runtime Library --
  14. -- Exception, version 3.1, as published by the Free Software Foundation. --
  15. -- --
  16. -- You should have received a copy of the GNU General Public License and --
  17. -- a copy of the GCC Runtime Library Exception along with this program; --
  18. -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
  19. -- <http://www.gnu.org/licenses/>. --
  20. -- --
  21. -------------------------------------------------------------------------------
  22. with AWS.Dispatchers.Callback;
  23. with AWS.Response;
  24. with Yolk.Configuration;
  25. with Yolk.Static_Content;
  26. package body Yolk.Handlers is
  27. -----------
  28. -- Set --
  29. -----------
  30. procedure Set
  31. (RH : out AWS.Services.Dispatchers.URI.Handler)
  32. is
  33. use AWS.Dispatchers.Callback;
  34. use Yolk.Configuration;
  35. package SC renames Yolk.Static_Content;
  36. Compressable_Callback : AWS.Response.Callback;
  37. begin
  38. if Config.Get (Compress_Static_Content) then
  39. Compressable_Callback := SC.Compressable'Access;
  40. else
  41. Compressable_Callback := SC.Non_Compressable'Access;
  42. end if;
  43. RH.Register_Regexp
  44. (URI => Config.Get (Handler_CSS),
  45. Action => Create (Callback => Compressable_Callback));
  46. RH.Register_Regexp
  47. (URI => Config.Get (Handler_GIF),
  48. Action => Create (Callback => SC.Non_Compressable'Access));
  49. RH.Register_Regexp
  50. (URI => Config.Get (Handler_HTML),
  51. Action => Create (Callback => Compressable_Callback));
  52. RH.Register_Regexp
  53. (URI => Config.Get (Handler_ICO),
  54. Action => Create (Callback => SC.Non_Compressable'Access));
  55. RH.Register_Regexp
  56. (URI => Config.Get (Handler_JPG),
  57. Action => Create (Callback => SC.Non_Compressable'Access));
  58. RH.Register_Regexp
  59. (URI => Config.Get (Handler_JS),
  60. Action => Create (Callback => Compressable_Callback));
  61. RH.Register_Regexp
  62. (URI => Config.Get (Handler_PNG),
  63. Action => Create (Callback => SC.Non_Compressable'Access));
  64. RH.Register_Regexp
  65. (URI => Config.Get (Handler_SVG),
  66. Action => Create (Callback => Compressable_Callback));
  67. RH.Register_Regexp
  68. (URI => Config.Get (Handler_XML),
  69. Action => Create (Callback => Compressable_Callback));
  70. RH.Register_Regexp
  71. (URI => Config.Get (Handler_XSL),
  72. Action => Create (Callback => Compressable_Callback));
  73. end Set;
  74. end Yolk.Handlers;