基于kore 的共享模块以及include 配置实现动态的web api 能力
kore 支持include 以及动态load 共享模块的能力,可以让我们实现动态扩展的api 加载能力
参考玩法
参考示例
- 项目结构
├── conf
│ ├── hello.conf
│ ├── index.conf
│ ├── mydemo.conf
│ └── myhello.conf
├── hello.so
└── mydemo.so
- 简单说明
hello.conf 是入口,index.conf 是一个汇总,通过include 包含了方法,mydemo.conf 以及myhello.conf 是基于共享模块的route 配置
hello.conf ,hello.so 以及mydemo.so 是基于kodev 开发构建的共享模块
hello.conf
server no_tls {
bind 0.0.0.0 8888
tls no
}
load ./mydemo.so
load ./hello.so
include conf/index.conf
http_server_version dalongdemo
index.conf
domain * {
attach no_tls
accesslog access.log
include conf/myhello.conf
include conf/mydemo.conf
}
myhello.conf
route /demo {
handler pagev2
methods GET
}
mydemo.conf
route / {
handler page
methods GET
}
- 运行
sudo kore -n -f -c conf/hello.conf
include 参考解析
如下,目前的那问题是不支持通配符的,不像nginx 那样可以支持通配符模式
static int
configure_include(char *path)
{
FILE *fp;
if ((fp = fopen(path, "r")) == NULL)
fatal("failed to open include '%s'", path);
kore_parse_config_file(fp);
(void)fclose(fp);
return (KORE_RESULT_OK);
}
说明
当然以上是一个简单的玩法,实际上基于include 以及分组可以实现比较灵活的配置集成
参考资料
https://github.com/jorisvink/kore
https://docs.kore.io/4.2.0/
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
2022-11-29 lavinmq cloudamqp 开源的amqp server
2022-11-29 一些不错的开源内网穿透工具
2022-11-29 一个历史k8s维护碰到的一些网络问题说明
2020-11-29 healthcheck一个不错的 Kubernetes liveness && readiness prob handler 实现
2020-11-29 proxysql proxy 集成golang-mysqlserver
2020-11-29 vernemq 典型的部署模型
2019-11-29 streamsets 官方默认镜像中文支持问题