Comments (5)
例如现在的新建 egin component 代码为:
server := egin.Load("server.http").Build()而我现在使用的一个旧项目已经在线上运行,更改 config 结构不方便,能否通过下面这种方式传入自定义配置项呢?
server := egin.Load("", egin.Config{Port: 9001, Host: "0.0.0.0"}).Build()
在Build里面有option更改这些属性
egin.DefaultContainer().Build(...)
from ego.
from ego.
![]()
master 分支的 egin options 并不支持直接更改 container.config, 只能更改一些定义好的 config option,并不能满足要求。
穷举所有的比较麻烦,所以不支持的,直接提pr。放进去就可以。
from ego.
👌
from ego.
看了 master 上的代码,其中 Build()
时已经有 econf.OnChange()
的依赖了, 用 option 的方式传入改动范围太大。后来者可以使用 econf.Apply()
方式接入 ego:
假设旧项目的配置文件不符合 ego component 配置格式,可以用 econf.Apply() 手动转换格式并应用,
// 项目配置应用到 econf
econf.Apply(map[string]interface{}{
"server": map[string]interface{}{
"http": map[string]interface{}{
"port": config.Port,
},
},
}
// ego.New 中会默认去加载配置文件,这里关闭掉
app := ego.New(ego.WithDisableFlagConfig(true))
from ego.
Related Issues (20)
- Error: undefined: Random in core/util/xcolor/string_windows.go HOT 1
- egin 支持https并且支持双向认证 HOT 3
- 有和业内众多web 框架的性能比较吗 HOT 1
- vscode 调试
- 请教一下脑图是什么软件画的 HOT 2
- 直接T群,真的没看懂
- go1.18.1版本存在模块兼容性问题
- ehttp client metrics use wrong label
- [doc] some links error in docs HOT 1
- apollo config promblem HOT 1
- build constraints exclude all Go files HOT 1
- 新版ego框架econf组件存在数据竞争问题 HOT 1
- [Feature]期望支持多配置文件
- 请问 ego 是否 支持 postgresql ? HOT 1
- same as / like douyu/jupiter? HOT 1
- about config HOT 4
- 提升测试用例覆盖率
- ekafka组件,当kafka挂掉,再重新启动后。服务是没有办法自动连接上kafka的 HOT 3
- ego的系统日志通过配置修改时使用赋值方式,导致ego结构体中的logger没有使用到最新的配置 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ego.