Giter VIP home page Giter VIP logo

Comments (5)

askuy avatar askuy commented on July 19, 2024

例如现在的新建 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.

zhan3333 avatar zhan3333 commented on July 19, 2024

image

master 分支的 egin options 并不支持直接更改 container.config, 只能更改一些定义好的 config option,并不能满足要求。

from ego.

askuy avatar askuy commented on July 19, 2024
image

master 分支的 egin options 并不支持直接更改 container.config, 只能更改一些定义好的 config option,并不能满足要求。

穷举所有的比较麻烦,所以不支持的,直接提pr。放进去就可以。

from ego.

zhan3333 avatar zhan3333 commented on July 19, 2024

👌

from ego.

zhan3333 avatar zhan3333 commented on July 19, 2024

看了 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.