I was thinking of adding some functionality to the...
# http4k
a
I was thinking of adding some functionality to the http4k-config package, specifically regarding optional files:
Copy code
/**
         * Load configuration from optional Properties file format on disk
         */
        fun fromOptionalFile(file: File): Environment = if (file.exists()) from(file) else EMPTY
Should I just submit a PR and explain my usecase or would you like me to create an issue first? This is a very simple change that has like 5-6 lines total of code (including tests)
a
Keeping in line with the existing method name convention of this module, I think a better signature might be something like:
Copy code
fun fromOrEmpty(file: File): Environment
Since the existing
from
doesn't mention file. Apart from that, you don't need to make an issue first. Just no guarantee the PR is accepted 🤷
j
Is this a common thing? I think it would be hard to know what your expected config would be, it just might be one thing or another.
a
Yeah i mean i would think that some kind of local dev environment file which is optional, is nice to have. As in each enviro usually has environment variables but locally I don’t want to deal with that but rather have some kind of file with secrets and things like that
a
I do something similar, except rather than check for the presence of the file, I only look for a file if one was provided in the program args.
Copy code
val env = args.firstOrNull()
    ?.let { Environment.from(File(it)) overrides Environment.ENV }
    ?: Environment.ENV