Fawkes API Fawkes Development Version
url_manager.h
1
2/***************************************************************************
3 * url_manager.h - Web URL manager
4 *
5 * Created: Thu Nov 25 21:53:07 2010
6 * Copyright 2006-2010 Tim Niemueller [www.niemueller.de]
7 *
8 ****************************************************************************/
9
10/* This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Library General Public License for more details.
19 *
20 * Read the full text in the LICENSE.GPL file in the doc directory.
21 */
22
23#ifndef _LIBS_WEBVIEW_URL_MANAGER_H_
24#define _LIBS_WEBVIEW_URL_MANAGER_H_
25
26#include <webview/request.h>
27#include <webview/router.h>
28
29#include <list>
30#include <mutex>
31
32namespace fawkes {
33
34class Mutex;
35class WebReply;
36template <typename T>
37class WebviewRouter;
38
40{
42
43public:
44 /** Function type for handling requests. */
45 typedef std::function<WebReply *(const WebRequest *)> Handler;
46
49
50 void add_handler(WebRequest::Method method, const std::string &path, Handler handler);
51 void remove_handler(WebRequest::Method method, const std::string &path);
52
53 void add_handler(WebRequest::Method method, const std::string &path, Handler handler, int weight);
54
55private:
56 WebReply *process_request(WebRequest *request);
57
58private:
59 std::mutex mutex_;
60 std::shared_ptr<WebviewRouter<Handler>> router_;
61};
62
63} // end namespace fawkes
64
65#endif
Basic web reply.
Definition: reply.h:34
Web request dispatcher.
Web request meta data carrier.
Definition: request.h:42
Method
HTTP transfer methods.
Definition: request.h:47
Manage URL mappings.
Definition: url_manager.h:40
std::function< WebReply *(const WebRequest *)> Handler
Function type for handling requests.
Definition: url_manager.h:45
void remove_handler(WebRequest::Method method, const std::string &path)
Remove a request processor.
Definition: url_manager.cpp:84
~WebUrlManager()
Destructor.
Definition: url_manager.cpp:42
WebUrlManager()
Constructor.
Definition: url_manager.cpp:37
void add_handler(WebRequest::Method method, const std::string &path, Handler handler)
Add a request processor.
Definition: url_manager.cpp:54
Fawkes library namespace.