SOIL C++
C++ Unified Device Interface
Resource.h
Go to the documentation of this file.
1#pragma once
2#include "constants.h"
3#include "Types.h"
4#include "cpprest/http_listener.h"
5#include <regex>
6#include <vector>
7
8namespace HTTP {
9
20 class DLL Resource
21 {
22 private:
34 Response fallback(Request message, std::smatch match = std::smatch());
35 protected:
42 std::vector<web::http::method> allowed_methods;
43
50 std::string content_type;
51
60 std::string allowed_origins;
61
69 void apply_headers(Response& response);
70 public:
76 Resource();
77
83 ~Resource();
84
96 static web::json::value request_info(Request message, std::smatch match = std::smatch());
97
109 virtual Response handle(Request message, std::smatch match = std::smatch());
110
122 virtual Response handle_get(Request message, std::smatch match = std::smatch());
123
135 virtual Response handle_put(Request message, std::smatch match = std::smatch());
136
148 virtual Response handle_post(Request message, std::smatch match = std::smatch());
149
161 virtual Response handle_delete(Request message, std::smatch match = std::smatch());
162
174 virtual Response handle_patch(Request message, std::smatch match = std::smatch());
175
187 virtual Response handle_options(Request message, std::smatch match = std::smatch());
188
200 virtual Response handle_head(Request message, std::smatch match = std::smatch());
201
213 virtual Response handle_exception(Request message, std::exception& exception, std::smatch match = std::smatch());
214 };
215}
216
HTTP Resource base class.
Definition: Resource.h:21
std::vector< web::http::method > allowed_methods
Allowed methods.
Definition: Resource.h:42
std::string allowed_origins
Allowed Origins.
Definition: Resource.h:60
std::string content_type
Content type.
Definition: Resource.h:50
Definition: Resource.h:8
web::http::http_request Request
HTTP Request.
Definition: Types.h:11
web::http::http_response Response
HTTP Response.
Definition: Types.h:18