PageRenderTime 20ms CodeModel.GetById 11ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/src/yolk-not_found.adb

http://github.com/ThomasLocke/yolk
Ada | 60 lines | 28 code | 8 blank | 24 comment | 0 complexity | 5f9cfe1e830604dd863eebd23ae4865f 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;
24with AWS.Messages;
25with AWS.MIME;
26with AWS.Templates;
27with Yolk.Configuration;
28
29package body Yolk.Not_Found is
30
31   --------------
32   --  Output  --
33   --------------
34
35   function Generate
36     (Request : in AWS.Status.Data)
37      return AWS.Response.Data
38   is
39      use AWS.Templates;
40      use Yolk.Configuration;
41
42      Content  : AWS.Response.Data;
43      T        : Translate_Set;
44   begin
45      Insert (T, Assoc ("RESOURCE", AWS.Status.URI (Request)));
46      Insert (T, Assoc ("VERSION", AWS.Version));
47      Insert (T, Assoc ("DOMAIN", String'(Config.Get (Server_Name))));
48
49      Content := AWS.Response.Build
50        (Content_Type  => AWS.MIME.Text_HTML,
51         Message_Body  => Parse
52           (Filename     => Config.Get (System_Templates_Path) &  "/404.tmpl",
53            Translations => T,
54            Cached       => True),
55         Status_Code   => AWS.Messages.S404);
56
57      return Content;
58   end Generate;
59
60end Yolk.Not_Found;