File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change 11#include < httpserver.hpp>
2+ #include < iostream>
23
34using namespace httpserver ;
45
56class hello_world_resource : public http_resource <hello_world_resource> {
67 public:
78 void render (const http_request&, http_response**);
9+ void set_some_data (const std::string &s) {data = s;}
10+ std::string data;
811};
912
1013// using the render method you are able to catch each type of request you receive
1114void hello_world_resource::render (const http_request& req, http_response** res)
1215{
16+ // it is possible to store data inside the resource object that can be altered
17+ // through the requests
18+ std::cout << " Data was: " << data << std::endl;
19+ std::string datapar = req.get_arg (" data" );
20+ set_some_data (datapar == " " ? " no data passed!!!" : datapar);
21+ std::cout << " Now data is:" << data << std::endl;
22+
1323 // it is possible to send a response initializing an http_string_response
1424 // that reads the content to send in response from a string.
1525 *res = new http_string_response (" Hello World!!!" , 200 );
You can’t perform that action at this time.
0 commit comments