heetch/confita

Add string support

defelmnq opened this issue · 0 comments

Looking for backend currently implemented I was asking myself about the utility of a new one able to handle strings given as parameter.

For exemple if the configuration is fetched from a remote URL (that returns it as a JSON or YAML etc..) - it could be nice to be able to include the fetched result in the config.

As you already are handling Unmarshaler here : ( https://github.com/heetch/confita/blob/master/config.go#L161 )
it could, for exemple, take the following form :

loader := confita.NewLoader(
  data.NewBackend(json.NewDecoder(content)), 
)

or, if for any reason you want to keep the content :

loader := confita.NewLoader(
  data.NewBackend(content, "json"), 
)

( maybe data is not the most relevant name tbh 🙈 )

for the rest it's pretty similar with what you already are doing in the file backend (just replacing the file operations part)