PageRenderTime 25ms CodeModel.GetById 1ms app.highlight 19ms RepoModel.GetById 1ms app.codeStats 1ms

/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 Lø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
23with AWS.Dispatchers.Callback;
24with AWS.Response;
25with Yolk.Configuration;
26with Yolk.Static_Content;
27
28package body Yolk.Handlers is
29
30   -----------
31   --  Set  --
32   -----------
33
34   procedure Set
35     (RH : out AWS.Services.Dispatchers.URI.Handler)
36   is
37      use AWS.Dispatchers.Callback;
38      use Yolk.Configuration;
39
40      package SC renames Yolk.Static_Content;
41
42      Compressable_Callback : AWS.Response.Callback;
43   begin
44      if Config.Get (Compress_Static_Content) then
45         Compressable_Callback := SC.Compressable'Access;
46      else
47         Compressable_Callback := SC.Non_Compressable'Access;
48      end if;
49
50      RH.Register_Regexp
51        (URI    => Config.Get (Handler_CSS),
52         Action => Create (Callback => Compressable_Callback));
53
54      RH.Register_Regexp
55        (URI    => Config.Get (Handler_GIF),
56         Action => Create (Callback => SC.Non_Compressable'Access));
57
58      RH.Register_Regexp
59        (URI    => Config.Get (Handler_HTML),
60         Action => Create (Callback => Compressable_Callback));
61
62      RH.Register_Regexp
63        (URI    => Config.Get (Handler_ICO),
64         Action => Create (Callback => SC.Non_Compressable'Access));
65
66      RH.Register_Regexp
67        (URI    => Config.Get (Handler_JPG),
68         Action => Create (Callback => SC.Non_Compressable'Access));
69
70      RH.Register_Regexp
71        (URI    => Config.Get (Handler_JS),
72         Action => Create (Callback => Compressable_Callback));
73
74      RH.Register_Regexp
75        (URI    => Config.Get (Handler_PNG),
76         Action => Create (Callback => SC.Non_Compressable'Access));
77
78      RH.Register_Regexp
79        (URI    => Config.Get (Handler_SVG),
80         Action => Create (Callback => Compressable_Callback));
81
82      RH.Register_Regexp
83        (URI    => Config.Get (Handler_XML),
84         Action => Create (Callback => Compressable_Callback));
85
86      RH.Register_Regexp
87        (URI    => Config.Get (Handler_XSL),
88         Action => Create (Callback => Compressable_Callback));
89   end Set;
90
91end Yolk.Handlers;