This commit is contained in:
eidheim 2016-09-07 09:30:31 +02:00
commit 8e5ff77421

View file

@ -57,13 +57,18 @@ int main() {
string name=pt.get<string>("firstName")+" "+pt.get<string>("lastName");
*response << "HTTP/1.1 200 OK\r\nContent-Length: " << name.length() << "\r\n\r\n" << name;
*response << "HTTP/1.1 200 OK" << "\r\n"
<< "Access-Control-Allow-Origin: *" << "\r\n"
<< "Content-Type: application/json" << "\r\n"
<< "Content-Length: " << name.length() << "\r\n"
<< "\r\n"
<< name;
}
catch(exception& e) {
*response << "HTTP/1.1 400 Bad Request\r\nContent-Length: " << strlen(e.what()) << "\r\n\r\n" << e.what();
}
};
//GET-example for the path /info
//Responds with request-information
server.resource["^/info$"]["GET"]=[](shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request) {