Created
April 4, 2017 04:39
-
-
Save herpiko/e4d58372ffade3044256b5881fa5238f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "server_http.hpp" | |
#include "client_http.hpp" | |
using namespace std; | |
typedef SimpleWeb::Server<SimpleWeb::HTTP> HttpServer; | |
int main() { | |
HttpServer server; | |
server.config.port=8000; | |
server.resource["^/ok$"]["GET"]=[](shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request) { | |
string ok = "ok"; | |
*response << "HTTP/1.1 200 OK\r\nContent-Length: " << ok.length() << "\r\n\r\n" << ok; | |
}; | |
server.resource["^/ok$"]["POST"]=[](shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request) { | |
auto foo=request->content.string(); | |
*response << "HTTP/1.1 200 OK\r\nContent-Length: " << foo.length() << "\r\n\r\n" << foo; | |
}; | |
server.start(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment