Skip to content
This repository was archived by the owner on Jun 12, 2018. It is now read-only.

Commit df5da94

Browse files
committed
renamed server.resources to server.resource
1 parent 00dbe0b commit df5da94

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

main_http.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ int main() {
1717

1818
//Add resources using regular expression for path, a method-string, and an anonymous function
1919
//POST-example for the path /string, responds the posted string
20-
server.resources["^/string/?$"]["POST"]=[](ostream& response, Request& request) {
20+
server.resource["^/string/?$"]["POST"]=[](ostream& response, Request& request) {
2121
//Retrieve string from istream (*request.content)
2222
stringstream ss;
2323
*request.content >> ss.rdbuf();
@@ -34,7 +34,7 @@ int main() {
3434
// "lastName": "Smith",
3535
// "age": 25
3636
//}
37-
server.resources["^/json/?$"]["POST"]=[](ostream& response, Request& request) {
37+
server.resource["^/json/?$"]["POST"]=[](ostream& response, Request& request) {
3838
try {
3939
ptree pt;
4040
read_json(*request.content, pt);
@@ -50,7 +50,7 @@ int main() {
5050

5151
//GET-example for the path /info
5252
//Responds with request-information
53-
server.resources["^/info/?$"]["GET"]=[](ostream& response, Request& request) {
53+
server.resource["^/info/?$"]["GET"]=[](ostream& response, Request& request) {
5454
stringstream content_stream;
5555
content_stream << "<h1>Request:</h1>";
5656
content_stream << request.method << " " << request.path << " HTTP/" << request.http_version << "<br>";
@@ -66,7 +66,7 @@ int main() {
6666

6767
//GET-example for the path /match/[number], responds with the matched string in path (number)
6868
//For instance a request GET /match/123 will receive: 123
69-
server.resources["^/match/([0-9]+)/?$"]["GET"]=[](ostream& response, Request& request) {
69+
server.resource["^/match/([0-9]+)/?$"]["GET"]=[](ostream& response, Request& request) {
7070
string number=request.path_match[1];
7171
response << "HTTP/1.1 200 OK\r\nContent-Length: " << number.length() << "\r\n\r\n" << number;
7272
};

main_https.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ int main() {
1717

1818
//Add resources using regular expression for path, a method-string, and an anonymous function
1919
//POST-example for the path /string, responds the posted string
20-
server.resources["^/string/?$"]["POST"]=[](ostream& response, Request& request) {
20+
server.resource["^/string/?$"]["POST"]=[](ostream& response, Request& request) {
2121
//Retrieve string from istream (*request.content)
2222
stringstream ss;
2323
*request.content >> ss.rdbuf();
@@ -34,7 +34,7 @@ int main() {
3434
// "lastName": "Smith",
3535
// "age": 25
3636
//}
37-
server.resources["^/json/?$"]["POST"]=[](ostream& response, Request& request) {
37+
server.resource["^/json/?$"]["POST"]=[](ostream& response, Request& request) {
3838
try {
3939
ptree pt;
4040
read_json(*request.content, pt);
@@ -50,7 +50,7 @@ int main() {
5050

5151
//GET-example for the path /info
5252
//Responds with request-information
53-
server.resources["^/info/?$"]["GET"]=[](ostream& response, Request& request) {
53+
server.resource["^/info/?$"]["GET"]=[](ostream& response, Request& request) {
5454
stringstream content_stream;
5555
content_stream << "<h1>Request:</h1>";
5656
content_stream << request.method << " " << request.path << " HTTP/" << request.http_version << "<br>";
@@ -66,7 +66,7 @@ int main() {
6666

6767
//GET-example for the path /match/[number], responds with the matched string in path (number)
6868
//For instance a request GET /match/123 will receive: 123
69-
server.resources["^/match/([0-9]+)/?$"]["GET"]=[](ostream& response, Request& request) {
69+
server.resource["^/match/([0-9]+)/?$"]["GET"]=[](ostream& response, Request& request) {
7070
string number=request.path_match[1];
7171
response << "HTTP/1.1 200 OK\r\nContent-Length: " << number.length() << "\r\n\r\n" << number;
7272
};

server_http.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace SimpleWeb {
2424
template <class socket_type>
2525
class ServerBase {
2626
public:
27-
resource_type resources;
27+
resource_type resource;
2828

2929
resource_type default_resource;
3030

@@ -34,7 +34,7 @@ namespace SimpleWeb {
3434
void start() {
3535
//All resources with default_resource at the end of vector
3636
//Used in the respond-method
37-
for(auto it=resources.begin(); it!=resources.end();it++) {
37+
for(auto it=resource.begin(); it!=resource.end();it++) {
3838
all_resources.push_back(it);
3939
}
4040
for(auto it=default_resource.begin(); it!=default_resource.end();it++) {

0 commit comments

Comments
 (0)