Renamed project name to 'cpp-httplib'.
This commit is contained in:
parent
8b58a3aecc
commit
6897c64c74
14
README.md
14
README.md
@ -1,14 +1,16 @@
|
|||||||
httpsvrkit
|
cpp-httplib
|
||||||
==========
|
===========
|
||||||
|
|
||||||
C++ HTTP sever library inspired by [Sinatra](http://www.sinatrarb.com/)
|
A C++ HTTP library.
|
||||||
|
|
||||||
[The Boost Software License 1.0](http://www.boost.org/LICENSE_1_0.txt)
|
[The Boost Software License 1.0](http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
Example
|
Server Example
|
||||||
-------
|
--------------
|
||||||
|
|
||||||
#include <httpsvrkit.h>
|
Inspired by [Sinatra](http://www.sinatrarb.com/)
|
||||||
|
|
||||||
|
#include <httplib.h>
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
HTTP_SERVER("localhost", 1234) {
|
HTTP_SERVER("localhost", 1234) {
|
||||||
|
@ -11,8 +11,8 @@ endif
|
|||||||
|
|
||||||
all: sample hello
|
all: sample hello
|
||||||
|
|
||||||
sample : sample.cc ../httpsvrkit.h
|
sample : sample.cc ../httplib.h
|
||||||
$(CC) -o sample $(CFLAGS) -I.. sample.cc
|
$(CC) -o sample $(CFLAGS) -I.. sample.cc
|
||||||
|
|
||||||
hello : hello.cc ../httpsvrkit.h
|
hello : hello.cc ../httplib.h
|
||||||
$(CC) -o hello $(CFLAGS) -I.. hello.cc
|
$(CC) -o hello $(CFLAGS) -I.. hello.cc
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
// The Boost Software License 1.0
|
// The Boost Software License 1.0
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <httpsvrkit.h>
|
#include <httplib.h>
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
// The Boost Software License 1.0
|
// The Boost Software License 1.0
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <httpsvrkit.h>
|
#include <httplib.h>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
using namespace httpsvrkit;
|
using namespace httplib;
|
||||||
|
|
||||||
template<typename Fn> void signal(int sig, Fn fn)
|
template<typename Fn> void signal(int sig, Fn fn)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// httpsvrkit.h
|
// httplib.h
|
||||||
//
|
//
|
||||||
// Copyright (c) 2012 Yuji Hirose. All rights reserved.
|
// Copyright (c) 2012 Yuji Hirose. All rights reserved.
|
||||||
// The Boost Software License 1.0
|
// The Boost Software License 1.0
|
||||||
@ -42,7 +42,7 @@ typedef int socket_t;
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
namespace httpsvrkit
|
namespace httplib
|
||||||
{
|
{
|
||||||
|
|
||||||
typedef std::map<std::string, std::string> Map;
|
typedef std::map<std::string, std::string> Map;
|
||||||
@ -457,18 +457,18 @@ inline void Server::process_request(FILE* fp_read, FILE* fp_write)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define HTTP_SERVER(host, port) \
|
#define HTTP_SERVER(host, port) \
|
||||||
for (std::shared_ptr<httpsvrkit::Server> svr_ = std::make_shared<httpsvrkit::Server>(host, port); \
|
for (std::shared_ptr<httplib::Server> svr_ = std::make_shared<httplib::Server>(host, port); \
|
||||||
svr_; \
|
svr_; \
|
||||||
svr_->run(), svr_.reset())
|
svr_->run(), svr_.reset())
|
||||||
|
|
||||||
#define GET(url, body) \
|
#define GET(url, body) \
|
||||||
svr_->get(url, [&](httpsvrkit::Context& cxt) { \
|
svr_->get(url, [&](httplib::Context& cxt) { \
|
||||||
const auto& req_ = cxt.request; \
|
const auto& req_ = cxt.request; \
|
||||||
auto& res_ = cxt.response; \
|
auto& res_ = cxt.response; \
|
||||||
body \
|
body \
|
||||||
});
|
});
|
||||||
|
|
||||||
} // namespace httpsvrkit
|
} // namespace httplib
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -9,7 +9,7 @@ CC = g++
|
|||||||
CFLAGS = -std=c++11 -g
|
CFLAGS = -std=c++11 -g
|
||||||
endif
|
endif
|
||||||
|
|
||||||
test : test.cc ../httpsvrkit.h
|
test : test.cc ../httplib.h
|
||||||
$(CC) -o test $(CFLAGS) -I.. -I. test.cc gtest/gtest-all.cc gtest/gtest_main.cc
|
$(CC) -o test $(CFLAGS) -I.. -I. test.cc gtest/gtest-all.cc gtest/gtest_main.cc
|
||||||
|
|
||||||
.PHONY : run
|
.PHONY : run
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <httpsvrkit.h>
|
#include <httplib.h>
|
||||||
#include <future>
|
#include <future>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace httpsvrkit;
|
using namespace httplib;
|
||||||
|
|
||||||
TEST(SplitTest, ParseQueryString)
|
TEST(SplitTest, ParseQueryString)
|
||||||
{
|
{
|
||||||
@ -55,7 +55,7 @@ TEST(ServerTest, GetMethod)
|
|||||||
{
|
{
|
||||||
Server svr("localhost", 1914);
|
Server svr("localhost", 1914);
|
||||||
|
|
||||||
svr.get("hi", [&](httpsvrkit::Context& cxt) {
|
svr.get("hi", [&](httplib::Context& cxt) {
|
||||||
cxt.response.set_content("Hello World!");
|
cxt.response.set_content("Hello World!");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user