forked from glynos/cpp-netlib
-
Notifications
You must be signed in to change notification settings - Fork 424
Expand file tree
/
Copy pathdynamic_dispatcher.hpp
More file actions
33 lines (26 loc) · 1.05 KB
/
dynamic_dispatcher.hpp
File metadata and controls
33 lines (26 loc) · 1.05 KB
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
// Copyright 2013 (c) Google, Inc.
// Copyright 2013 (c) Dean Michael Berris <dberris@google.com>
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef NETWORK_HTTP_SERVER_DYNAMIC_DISPATCHER_HPP_20130327
#define NETWORK_HTTP_SERVER_DYNAMIC_DISPATCHER_HPP_20130327
#include <http/server/session.hpp>
#include <http/server/connection.hpp>
#include <string>
#include <functional>
#include <memory>
#include <unordered_map>
namespace network {
namespace http {
struct dynamic_dispatcher{
void register_handler(boost::string_ref pattern, std::function<void(session&, std::shared_ptr<connection>)> handler);
void dispatch(boost::string_ref path, session& s, std::shared_ptr<connection> c);
private:
std::unordered_map<
std::string,
std::function<void(session &, std::shared_ptr<connection>)> > handlers_;
};
} // namespace http
} // namespace network
#endif /* end of include guard: NETWORK_HTTP_SERVER_DYNAMIC_DISPATCHER_HPP_20130327 */