c++ study
Our project is to implement following yaml
- RestServer class
- non copyable, movable, may create multiple server
class RestServer
{
public:
// create rest server with given url
RestServer(const std::string& url);
// close server. stop if it's running.
~RestServer();
// can handle request after this api
// doesn't block thread
void Run();
// add handler when given url is called with GET method
void OnGet(const std::string& url, SynchronousHandler handler);
// add handler when given url is called with POST method
void OnPost(const std::string& url, SynchronousHandler handler);
};
struct Request {
const web::http::uri& uri() const;
};
struct Response {
Response(const std::string& message);
web::http::status_code code() const;
};
// closure of Response operator() (const Request&) const
typename SynchronousHandler;
class MyRestAppInitialiser
{
// create a rest server with api
std::shared_ptr<RestServer> CreateServer();
};
TBD: apply TDD
TBD: make your own complex handler
TBD: attach other module (ex. web parsing)
TBD: create real-world application (ex. discord command line bot)