- 博客(0)
- 资源 (4)
- 收藏
- 关注
HttpServer.zip
自写的HttpServer,实现简单的Get请求服务器。
内含测试代码,通过几行代码就可以轻松开启一个Http服务(仅限于Get请求)。
适合做一些简易的Http接口,如:一个接口通过访问http://localhost:8080/getAddNum?a=1&b=2来获取a和b的和,动态库会帮你接收到请求,并将地址解析成getAddNum,和参数的容器,使用者不必解析参数,动态库会帮忙解析。使用者可以轻松的将两数相加并返回。
代码示例:
#include "stdafx.h"
static int __stdcall HttpCallBack(std::string &strBuffer, std::string strFun, std::vector<UrlPar> vUrlPar);
int _tmain(int argc, _TCHAR* argv[])
{
HttpServer httpServer(HttpCallBack);
int nRet = httpServer.CreateServer(7002);
Sleep(3600000);
return 0;
}
int __stdcall HttpCallBack(std::string &strBuffer, std::string strFun, std::vector<UrlPar> vUrlPar)
{
strBuffer = "你是我的小呀小苹果";
return 0;
}
2020-01-19
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人