0

Good day. I am working on some Library-type projects that are in charge of communicating with different APIs and are called from a web application, I need to know what can be the best approach to switch between development and production endpoints inside the library projects. I thought about defining an environment variable that I create on my local computer and based on that variable take a configuration file or another depending on whether that variable exists or not.

On the other hand, I'm not sure how to create and take the values from that configuration file.

Some clue? Thanks

  • *"I'm not sure how to ..."* - it's worth to do research then. It's good what you posted the original problem, but why giving up so early? You have idea, check it. It may just work. – Sinatr Dec 18 '20 at 13:25
  • Don't do this. In general, library should accept settings through its public API. It could be settings object or settings provider, which is passed to some public library method/constructor etc. Reading settings from any kind of storage (environment variables, config files, databases) is not a library responsibility. Normally, host application decides where to store it's settings. – Dennis Dec 18 '20 at 13:31

0 Answers0