SOIL C++
C++ Unified Device Interface
Server.h
Go to the documentation of this file.
1#pragma once
2#include "constants.h"
3#include "cpprest/http_listener.h"
4#include "Resource.h"
5
6using namespace web;
7using namespace http;
8using namespace utility;
9using namespace http::experimental::listener;
10
11namespace HTTP
12{
21 class DLL Server
22 {
23 private:
29 Resource default_resource;
30
37 std::vector<std::pair<std::string, std::shared_ptr<Resource> > > resources;
38
49 void handle(http_request message);
50
51
57 http_listener listener;
58
59 public:
69 Server(std::string url);
70
77 ~Server();
78
84 inline void open() { listener.open().wait(); }
85
91 inline void close() { listener.close().wait(); }
92
104 void add(std::string path, std::shared_ptr<Resource> resource);
105
114 void remove(std::string path);
115
116 };
117}
118
HTTP Resource base class.
Definition: Resource.h:21
HTPP Server.
Definition: Server.h:22
void close()
Stop listener.
Definition: Server.h:91
void open()
Start listener.
Definition: Server.h:84
Definition: Resource.h:8