AnCH Framework 0.1
Another C++ Hack Framework
Loading...
Searching...
No Matches
router.hpp
1/*
2 ANCH Framework: ANother C++ Hack is a C++ framework based on C++11 standard
3 Copyright (C) 2020 Vincent Lachenal
4
5 This file is part of ANCH Framework.
6
7 ANCH Framework is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 ANCH Framework is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with ANCH Framework. If not, see <http://www.gnu.org/licenses/>.
19*/
20#pragma once
21
22#include <map>
23#include <functional>
24
25#include "rest/request.hpp"
26#include "rest/response.hpp"
27#include "rest/endpoint.hpp"
28#include "rest/endpointFunction.hpp"
29
30
31namespace anch::rest {
32
48 class Router {
49
50 // Attributes +
51 private:
53 std::map<EndPoint, EndpointFunc*> _routes;
54 // Attributes -
55
56 // Constructors +
57 public:
62 // Constructors -
63
64 // Destructor +
65 public:
66 virtual ~Router();
67 // Destructor -
68
69 // Methods +
70 public:
84 template<typename... P>
85 Router& add(std::function<anch::rest::Response(const anch::rest::Request&, P...)> func,
86 const std::string& path,
87 const std::string& verb,
88 const std::vector<std::string>& consumes,
89 const std::vector<std::string>& produces);
90
101 template<typename... P>
102 Router& add(anch::rest::EndPoint& endpoint, std::function<anch::rest::Response(const anch::rest::Request&, P...)> func);
103
112 // Methods -
113
114 };
115
116} // anch::rest
117
118#include "rest/impl/router.hpp"
Router endpoint.
Definition endpoint.hpp:40
HTTP request.
Definition request.hpp:43
HTTP response.
Definition response.hpp:45
Router & add(anch::rest::EndPoint &endpoint, std::function< anch::rest::Response(const anch::rest::Request &, P...)> func)
anch::rest::Response execute(anch::rest::Request &request) noexcept
Router & add(std::function< anch::rest::Response(const anch::rest::Request &, P...)> func, const std::string &path, const std::string &verb, const std::vector< std::string > &consumes, const std::vector< std::string > &produces)