updated comments

This commit is contained in:
eidheim 2014-07-05 13:10:44 +02:00
commit 65d267963d

View file

@ -10,7 +10,7 @@ using namespace boost::property_tree;
int main() { int main() {
//HTTP-server at port 8080 using 4 threads //HTTP-server at port 8080 using 4 threads
HTTPServer httpserver(8080, 4); HTTPServer httpserver(8080, 1);
//Add resources using regular expressions for path and method //Add resources using regular expressions for path and method
//POST-example for the path /string, responds the posted string //POST-example for the path /string, responds the posted string
@ -50,13 +50,14 @@ int main() {
response << "HTTP/1.1 200 OK\r\nContent-Length: 13\r\n\r\nRoot resource"; response << "HTTP/1.1 200 OK\r\nContent-Length: 13\r\n\r\nRoot resource";
}; };
//GET-example for the path /test, responds with the matched string in path (test) //GET-example for the path /match/[number], responds with the matched string in path (number)
httpserver.resources["^/(test)/?$"]["^GET$"]=[](ostream& response, const Request& request, const smatch& path_match) { httpserver.resources["^/match/([0-9]*)/?$"]["^GET$"]=[](ostream& response, const Request& request, const smatch& path_match) {
response << "HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\n" << path_match[1]; string number=path_match[1];
response << "HTTP/1.1 200 OK\r\nContent-Length: " << number.length() << "\r\n\r\n" << number;
}; };
//Start HTTP-server //Start HTTP-server
httpserver.start(); httpserver.start();
return 0; return 0;
} }