具备简单的集成性基础功能。
模块架构:
- acc(接受请求)
- rsc(响应+调度器实现)
- RESRC(资源池)https://github.com/yauntyour/RESRC
- com(中心封装和集成)
全部二次封装&集成&C++ class封装于appweb.h
。
详细内容
example dome:
1 |
|
基本使用:
注册一个Varde,其结构为
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28/*
necessary arg:
char* Name -A node's Name;
func_cb func -A deal by function;
int req_Type -request model;
struct varde *list -A node list this node;
size_t list_length, list_size -The list's length & size;
int ComPath -Common path resolution:true or false;
if req_model == -1,it will disable this Varde;
*/
typedef struct varde
{
func_cb func;
int req_Type;
char *Name; // The Name of varde
struct varde *list;
size_t list_length, list_size;
int ComPath; // Common path resolution:true or false
int append(struct varde *Var);
int ZIP()
} Varde;
//函数类型为:
//利用该宏可以快速定义一个标准函数(参见example dome)
//理论上根据规范,您需要返回一个HTTP状态码检查函数执行,因为在调度器中不会检查函数的执行是否正常,这就要您在编写函数时调试完成。我们提供一个快捷注册的宏
1
2
3
4
5
//eg: Varde var = Varde_def(test,req_ALL,"test",ComPath_True);使用
app.start(flag_wait);
执行服务。执行端会监听您提供的port。flag设置为0表示默认阻塞运行。
相关基础信息:
1 | typedef struct appev |
SDK&Debug&Python实现的调试工具
nc.py
1
2
3
4
5
6
7
8
9
10
11
12#参数
if sys.argv[1] == '-nc':
netcat()
elif sys.argv[1] == '-cli':
UDPclientSend()
elif sys.argv[1] == '-server':
Server()
else:
print("no this mode")
print("argv format: -mode host port recvbufflen/data (Server socketTypes:STREAM/DGRAM)")
##argv format: -mode host port recvbufflen/data (Server socketTypes:STREAM/DGRAM)
#eg :python nc.py -cli 127.0.0.1 10000 1280 STREAMnetools.py
1
2
3
4
5
6
7
8#可以自行修改msg的内容
msg = "GET /home HTTP/1.1\r\nHost: localhost\r\nUser-Agent: Mozilla/5.0 (Windows NT 5.1; rv:10.0.2) Gecko/20100101 Firefox/10.0.2\r\n\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8\r\nAccept-Language: zh-cn,zh;q=0.5\r\nAccept-Encoding: gzip, deflate\r\nConnection: keep-alive\r\nReferer: http://localhost/\r\nContent-Length: 25\r\nContent-Type: application/x-www-form-urlencoded\r\nusername=aa&password=1234"
if sys.argv[1] == '-nc':
netcat()
else:
print("argv format: -mode host port recvbufflen")
#argv format: -mode host port recvbufflennetcat 自行到官网下载最新版本
后续更新信息
- 加入zlib支持gzip压缩
- 改进RESRC资源池设计
- 支持HTTP2-3
- UDP接口开放