ESP32 HTTPS Server
ResourceParameters.hpp
1 #ifndef SRC_RESOURCEPARAMETERS_HPP_
2 #define SRC_RESOURCEPARAMETERS_HPP_
3 
4 #include <Arduino.h>
5 
6 #include <string>
7 // Arduino declares it's own min max, incompatible with the stl...
8 #undef min
9 #undef max
10 #include <vector>
11 #include <utility>
12 
13 #include "util.hpp"
14 
15 namespace httpsserver {
16 
17 class ResourceResolver;
18 
32 public:
34  virtual ~ResourceParameters();
35 
36  bool isQueryParameterSet(std::string const &name);
37  bool getQueryParameter(std::string const &name, std::string &value);
38  std::vector<std::pair<std::string,std::string>>::iterator beginQueryParameters();
39  std::vector<std::pair<std::string,std::string>>::iterator endQueryParameters();
40  size_t getQueryParameterCount(bool unique=false);
41  bool getPathParameter(size_t const idx, std::string &value);
42  std::string getPathParameter(size_t const idx);
43 
44 protected:
45  friend class ResourceResolver;
46  void setQueryParameter(std::string const &name, std::string const &value);
47  void resetPathParameters();
48  void setPathParameter(size_t idx, std::string const &val);
49 
50 private:
52  std::vector<std::string> _pathParams;
54  std::vector<std::pair<std::string, std::string>> _queryParams;
55 };
56 
57 } /* namespace httpsserver */
58 
59 #endif /* SRC_RESOURCEPARAMETERS_HPP_ */
bool getQueryParameter(std::string const &name, std::string &value)
Returns an HTTP query parameter.
Definition: ResourceParameters.cpp:48
The ResourceParameters provide access to the parameters passed in the URI.
Definition: ResourceParameters.hpp:31
size_t getQueryParameterCount(bool unique=false)
Returns the number of query parameters.
Definition: ResourceParameters.cpp:67
std::vector< std::pair< std::string, std::string > >::iterator beginQueryParameters()
Provides iterator access to the query parameters.
Definition: ResourceParameters.cpp:98
This class is used internally to resolve a string URL to the corresponding HTTPNode.
Definition: ResourceResolver.hpp:22
bool getPathParameter(size_t const idx, std::string &value)
Checks for the existence of a path parameter and returns it as string.
Definition: ResourceParameters.cpp:129
bool isQueryParameterSet(std::string const &name)
Checks whether a specific HTTPS query parameter is set.
Definition: ResourceParameters.cpp:24
std::vector< std::pair< std::string, std::string > >::iterator endQueryParameters()
Counterpart to beginQueryParameters() for iterating over query parameters.
Definition: ResourceParameters.cpp:105
Definition: ConnectionContext.cpp:3