root/http/recovered.cc

Revision 751fac6b567d675afee10e627efb5cf786ce5c83, 2.5 KB (checked in by Antti-Juhani Kaijanaho <antti-juhani@…>, 21 months ago)

[http::request] Cleanup

Signed-off-by: Antti-Juhani Kaijanaho <antti-juhani@…>

  • Property mode set to 100644
Line 
1/*  This file is part of Alue, the multiprotocol Internet discussion daemon
2
3    Copyright © 2009, 2010 Antti-Juhani Kaijanaho
4
5    Alue is free software: you can redistribute it and/or modify it
6    under the terms of the GNU General Public License as published by
7    the Free Software Foundation, either version 3 of the License, or
8    (at your option) any later version.
9
10    Alue is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with Alue.  If not, see <http://www.gnu.org/licenses/>.
17
18 */
19
20#include "authn.hh"
21#include "error_resource.hh"
22#include "redir_resource.hh"
23#include "request.hh"
24#include "templated_resource.hh"
25#include "response.hh"
26#include "token.hh"
27
28#include "../config.hh"
29#include "../db/db.hh"
30#include "../db/user.hh"
31#include "../html/util.hh"
32#include "../msg/lexutils.hh"
33#include "../server.hh"
34#include "../smtp_client/smtp_client.hh"
35#include "../tlate/tlate.hh"
36#include "../util.hh"
37
38#include <boost/shared_ptr.hpp>
39
40namespace http
41{
42        class recovered : public templated_resource
43        {
44        public:
45                recovered(server::conn_cb cb)
46                        : templated_resource(cb, "recovered.html")
47                        {}
48        protected:
49                void set_attributes(boost::shared_ptr<request>,
50                                    tlate::data_model::ptr);
51        };
52
53        void recovered::set_attributes(boost::shared_ptr<request> req,
54                                       tlate::data_model::ptr am)
55        {
56                std::string (*const q)(std::string,bool) = html::quote;
57                std::string (*const dep)(std::string) = uri::percent_decode;
58
59                std::string user = dep(req->get_form_field("userid"));
60                am->insert("userid", q(user,false));
61        }
62}
63
64namespace
65{
66        class factory : public server::http_resource_factory
67        {
68        public:
69                factory() {
70                        server::register_http_resource("/recovered", this);
71                }
72                boost::shared_ptr<http::resource> operator()
73                (server::conn_cb cb, std::string) {
74                        boost::shared_ptr<http::resource> rv
75                                (new http::recovered(cb));
76                        return rv;
77                }
78        };
79        factory f;
80}
Note: See TracBrowser for help on using the browser.