webgm_utils
简介
提供webgm操作相关的工具库
组件接口
FUrlWhitelist.gs
URL的白名单标记
webgm_cmds.gs
webgm的消息号处理
函数原型 | 函数作用 |
---|---|
void add_handler(string url, function func) | 注册handler |
void add_handler_forward_func(function func) | 添加前置处理函数 |
bool call_handler_forward_funcs(mixed req, mixed res) | 执行所有前置处理函数 |
void add_handler_backward_func(function func) | 添加后置处理函数 |
bool call_handler_backward_funcs(mixed req, mixed res) | 执行所有后置处理函数 |
void register_all_handlers(string dir, string prefix = "/") | 将指定文件夹下的文件注册成handler |
void register_internal_filters(array files) | 提供注册内部使用的filters |
webgm_hotfix.gs
webgm的热修复相关逻辑
webgm_post.gs
webgm的请求发送
函数原型 | 函数作用 |
---|---|
map post(string url, mixed data = nil, int type = Content_Type.json, map headers = , map extra = ) | 发送post请求(规范返回值) |
map co_execute_async_by_urls(function handle_func, map url2data = , int timeout = 5) | 异步执行相关urls的操作(handle_func) |
map co_execute_async(function handle_func, map key2data = , int timeout = 5) | 异步执行相关keys的操作(handle_func) |
webgm_resp.gs
webgm的回包处理
枚举
ResponseCode
Success = 200, // 求成功
Failure = 400, // 请求失败
Illegal = 404, // 请求参数不合法/缺失
UnAuthorized = 401, // 未认证
Forbidden = 403, // 没有权限
Download = 1001 // 下载文件