@@ -74,6 +74,16 @@ namespace webframe
7474 class request
7575 {
7676 public:
77+ /* *
78+ * @brief URL variables extracted from the request path
79+ * @details If the request path matches a route with variables, the variables will be extracted
80+ * and stored in this vector. The order of the variables corresponds to the order of the placeholders
81+ * in the route definition.
82+ *
83+ * TODO: find a cleaner way to do this.
84+ */
85+ std::vector<std::string> path_variables;
86+
7787 /* *
7888 * @brief get the HTTP method of the request
7989 * @return the HTTP method of the request
@@ -86,30 +96,30 @@ namespace webframe
8696 virtual std::string get_path () const = 0;
8797
8898 virtual std::string get_uri () const = 0;
89-
99+
90100 /* *
91101 * @brief get the value of a specific header
92102 * @param key the header key
93103 * @param value reference to the header value
94- * @return true if the header exists, false otherwise. The string reference will only
104+ * @return true if the header exists, false otherwise. The string reference will only
95105 * be set if the header exists.
96106 */
97107 virtual bool get_header (const std::string &key, std::string &value) const = 0;
98108
99109 /* *
100110 * @brief get the body of the request as a pointer and size
101111 * @return a pair containing a pointer to the body data and the size of the body
102- * @details The body data is not guaranteed to be null-terminated. The pointer and size are only
103- * valid for the duration of the request handling. If the request does not have a body, the pointer
112+ * @details The body data is not guaranteed to be null-terminated. The pointer and size are only
113+ * valid for the duration of the request handling. If the request does not have a body, the pointer
104114 * will be null and the size will be zero.
105115 */
106116 virtual std::pair<const uint8_t *, size_t > get_body () const = 0;
107117
108118 /* *
109119 * @brief read the body of the request using a callback
110120 * @param callback a function to be called with the body data and size
111- * @details The callback will be called with chunks of the body data. None of the runtimes are
112- * currently capable of streaming request bodies, so the callback will be called at most once with the
121+ * @details The callback will be called with chunks of the body data. None of the runtimes are
122+ * currently capable of streaming request bodies, so the callback will be called at most once with the
113123 * entire body. If there is no request body, the callback will not be called.
114124 */
115125 virtual void read_body (const std::function<void (const uint8_t *, size_t )> &callback) const = 0;
@@ -126,34 +136,34 @@ namespace webframe
126136 /* *
127137 * @brief set the HTTP status code of the response
128138 * @param status_code the HTTP status code
129- * @details The status code is not checked against valid HTTP status codes. It can be set to
139+ * @details The status code is not checked against valid HTTP status codes. It can be set to
130140 * any integer value, but there is no guarantee that the runtime implementation will accept it.
131141 */
132142 virtual void set_status (int status_code) = 0;
133-
143+
134144 /* *
135145 * @brief set a header of the response
136146 * @param key the header key
137147 * @param value the header value
138148 * @details The headers are not validated, and there is no standard way to handle duplicate entries.
139149 */
140150 virtual void set_header (const std::string &key, const std::string &value) = 0;
141-
151+
142152 /* *
143153 * @brief set the body of the response
144154 * @param data pointer to the body data
145155 * @param size the size of the body data
146- * @details This must be called once after the status and headers have been set. If it is called
147- * before, the status will be 200 and the headers will be empty. There is no standard way to handle
156+ * @details This must be called once after the status and headers have been set. If it is called
157+ * before, the status will be 200 and the headers will be empty. There is no standard way to handle
148158 * multiple calls.
149159 */
150160 virtual void set_body (const uint8_t *data, size_t size) = 0;
151161
152162 /* *
153163 * @brief write the body of the response using a callback
154164 * @param callback a function to be called with a chunk to set the body data and size.
155- * @details The callback will be called with chunks of the body data until it returns false to indicate
156- * end-of-stream. The callback will always be called at least once, and will only populate the chunk if
165+ * @details The callback will be called with chunks of the body data until it returns false to indicate
166+ * end-of-stream. The callback will always be called at least once, and will only populate the chunk if
157167 * the data is not null and the size is greater than zero.
158168 */
159169 virtual void write_body (const std::function<bool (std::pair<const uint8_t *, size_t > &)> &callback) = 0;
@@ -162,7 +172,7 @@ namespace webframe
162172 /* *
163173 * @class runtime
164174 * @brief abstract interface for WebFrame runtimes
165- * @details Given an application and a router, the runtime is responsible for abstracting HTTP traffic from the
175+ * @details Given an application and a router, the runtime is responsible for abstracting HTTP traffic from the
166176 * underlying platform. The user will rarely, if ever, interact with this interface directly.
167177 */
168178 class runtime
@@ -178,7 +188,7 @@ namespace webframe
178188 * @param a the application to dispatch
179189 * @param r the router to use for dispatching requests
180190 * @return the exit code of the application
181- * @details This is only used for the Win32 desktop runtime. You should not call this directly. Use the WEBFRAME_MAIN macro
191+ * @details This is only used for the Win32 desktop runtime. You should not call this directly. Use the WEBFRAME_MAIN macro
182192 * to define the entry point of your application, and it will call this function for you.
183193 */
184194 virtual int dispatch (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow, application *a, router *r) = 0;
@@ -190,7 +200,7 @@ namespace webframe
190200 * @param a the application to dispatch
191201 * @param r the router to use for dispatching requests
192202 * @return the exit code of the application
193- * @details This is used for all non-Win32 runtimes, including Windows servers. Like the other dispatch function, it
203+ * @details This is used for all non-Win32 runtimes, including Windows servers. Like the other dispatch function, it
194204 * should not be called directly.
195205 */
196206 virtual int dispatch (int argc, const char **argv, application *a, router *r) = 0;
0 commit comments