aboutsummaryrefslogtreecommitdiff
path: root/web/apache/service
blob: 3c7a39864a1c720d70d0923fa7d5655d8980b09d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// file      : web/apache/service -*- C++ -*-
// copyright : Copyright (c) 2014-2015 Code Synthesis Tools CC
// license   : MIT; see accompanying LICENSE file

#ifndef WEB_APACHE_SERVICE
#define WEB_APACHE_SERVICE

#include <string>

#include <web/module>

namespace web
{
  namespace apache
  {
    class service_common
    {
      //@@ Implementation that calls handle() below goes here.
      //

      virtual void
      handle (request&, response&, log&) = 0;
    };

    template <typename M>
    class service: public service_common
    {
    public:
      // Note that the module exemplar is stored by-reference.
      //
      service (const std::string& name, const M& exemplar);

      virtual void
      handle (request& rq, response& rs, log& l)
      {
        M m (exemplar_);
        m.handle (rq, rs, l);
      }

    private:
      const M& exemplar_;
    };
  }
}

#endif // WEB_APACHE_SERVICE