cpp-httplib/README.md

47 lines
975 B
Markdown
Raw Normal View History

2012-09-27 18:05:36 -07:00
cpp-httplib
===========
2012-09-21 19:38:33 -07:00
A C++11 header-only HTTP library.
2012-09-22 21:41:21 -07:00
[The Boost Software License 1.0](http://www.boost.org/LICENSE_1_0.txt)
It's extremely easy to setup. Just include **httplib.h** file in your code!
2012-09-27 18:05:36 -07:00
Server Example
--------------
2012-10-12 13:09:39 -07:00
Inspired by [Sinatra](http://www.sinatrarb.com/) and [express](https://github.com/visionmedia/express).
2012-09-27 18:05:36 -07:00
#include <httplib.h>
int main(void)
{
using namespace httplib;
2012-10-12 13:09:39 -07:00
Server svr;
svr.get("/hi", [](const auto& req, auto& res) {
2012-10-12 13:09:39 -07:00
res.set_content("Hello World!", "text/plain");
});
2012-10-12 13:09:39 -07:00
svr.listen("localhost", 1234);
}
Client Example
--------------
#include <httplib.h>
#include <iostream>
int main(void)
{
httplib::Client cli("localhost", 1234);
auto res = cli.get("/hi");
if (res && res->status == 200) {
std::cout << res->body << std::endl;
}
}
Copyright (c) 2014 Yuji Hirose. All rights reserved.