FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
esp32_https_server/src/HTTPNode.hpp at master · open-morphs/esp32_https_server · GitHub
This repository was archived by the owner on Dec 29, 2023. It is now read-only.
open-morphs
esp32_https_server
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
esp32_https_server
/
src
/
HTTPNode.hpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
70 lines (56 loc) · 1.93 KB
Breadcrumbs
esp32_https_server
/
src
/
HTTPNode.hpp
Copy path
File metadata and controls
70 lines (56 loc) · 1.93 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#
ifndef
SRC_HTTPNODE_HPP_
#
define
SRC_HTTPNODE_HPP_
#
include
<
Arduino.h
>
#
include
<
string
>
#
undef
min
#
undef
max
#
include
<
vector
>
#
include
"
HTTPValidator.hpp
"
namespace
httpsserver
{
enum
HTTPNodeType {
/*
* Node with a handler callback function (class ResourceNode)
*/
HANDLER_CALLBACK
,
/*
* Node with a websocket handler (class WebsocketNode)
*/
WEBSOCKET
};
/*
*
* \brief Base class for a URL/route-handler in the server.
*
* Use ResourceNode for requests that access dynamic or static resources or HttpNode for routes that
* create Websockets.
*/
class
HTTPNode
{
public:
HTTPNode
(
const
std::string &path,
const
HTTPNodeType nodeType,
const
std::string &tag =
"
"
);
virtual
~HTTPNode
();
/*
*
* The path under which this node will be available. Should start with a slash. Example:
* "/myResource"
*/
const
std::string _path;
/*
*
* Stores a tag that can be used in middleware and handler functions to identify this
* specific node, tag the node with a required permission, ...
*/
const
std::string _tag;
/*
* Stores the type of the node (as we have not runtime type information by default)
*/
const
HTTPNodeType _nodeType;
bool
hasPathParameter
();
size_t
getPathParamCount
();
ssize_t
getParamIdx
(
size_t
);
std::vector<HTTPValidator*> *
getValidators
();
virtual
std::string
getMethod
() = 0;
/*
*
* Adds a validation function that checks if the actual value of a parameter matches the expectation
* @param paramIdx defines the ID of the parameter that should be checked (starts by 0)
* @param validator the function (string -> bool) that checks if the parameter matches the expecatation
*
* @see ValidatorFunctions.hpp if you need some predefined templates for functions
*/
void
addPathParamValidator
(
size_t
paramIdx,
const
HTTPValidationFunction * validator);
private:
std::vector<
size_t
> _pathParamIdx;
std::vector<HTTPValidator*> _validators;
};
}
//
namespace httpserver
#
endif
Back
|
FazBrowse Home
|
New Git URL