Added syntax highlight to samples.
This commit is contained in:
parent
79bb0be0ca
commit
de645fffc0
1 changed files with 28 additions and 19 deletions
|
@ -12,6 +12,7 @@ Server Example
|
||||||
|
|
||||||
Inspired by [Sinatra](http://www.sinatrarb.com/) and [express](https://github.com/visionmedia/express).
|
Inspired by [Sinatra](http://www.sinatrarb.com/) and [express](https://github.com/visionmedia/express).
|
||||||
|
|
||||||
|
```c++
|
||||||
#include <httplib.h>
|
#include <httplib.h>
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
|
@ -24,12 +25,19 @@ Inspired by [Sinatra](http://www.sinatrarb.com/) and [express](https://github.co
|
||||||
res.set_content("Hello World!", "text/plain");
|
res.set_content("Hello World!", "text/plain");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
svr_.get("/numbers/(\d+)", [&](const auto& req, auto& res) {
|
||||||
|
string numbers = req.matches[1];
|
||||||
|
res.set_content(numbers, "text/plain");
|
||||||
|
});
|
||||||
|
|
||||||
svr.listen("localhost", 1234);
|
svr.listen("localhost", 1234);
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
Client Example
|
Client Example
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
```c++
|
||||||
#include <httplib.h>
|
#include <httplib.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
@ -42,5 +50,6 @@ Client Example
|
||||||
std::cout << res->body << std::endl;
|
std::cout << res->body << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
Copyright (c) 2014 Yuji Hirose. All rights reserved.
|
Copyright (c) 2014 Yuji Hirose. All rights reserved.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue