nitrogen / simple_bridge

A simple, standardized interface library to Erlang HTTP Servers.
MIT License
112 stars 76 forks source link

How to set different location for simple_bridge.config when using simple_bridge:start(...) #82

Closed leondavi closed 6 months ago

leondavi commented 8 months ago

I would want to load the configuration file and start simple_bridge server from another supervisor module. Is there an option to set a path to the configuration file on run-time?

choptastic commented 8 months ago

Hi @leondavi ,

There is nothing particularly special about the location of simple_bridge.config. In your app, you can simply put the configuration options in your app.config and when simple_bridge loads, it'll bring in the configuration from your app.config.

Alternatively, you can load the application, then use things like application:set_env/[1-4] to set the configuration terms for custom configuration.

leondavi commented 8 months ago

Hi @leondavi ,

There is nothing particularly special about the location of simple_bridge.config. In your app, you can simply put the configuration options in your app.config and when simple_bridge loads, it'll bring in the configuration from your app.config.

Alternatively, you can load the application, then use things like application:set_env/[1-4] to set the configuration terms for custom configuration.

Thanks!

choptastic commented 8 months ago

Of course! I hope that helps. I'm also open, if you're feeling spicy and wanting to add some functionality, I'm open to merging a pull request that adds another clause to simple_bridge:start/1 for simple_bridge:start(Config) where Config can be either any of the following:

1) A string to represent the location of a config file to load, 2) A map or proplist of the terms of the simple_bridge configuration (e.g. [{port, 8000}, {address, "0.0.0.0"}, ...]) 3) A 2-tuple of {Module, Function} that could then call Module:Function() which would return the same kind of values as represented in (2).

That is, if you're feeling up to it :)