Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new variant in enum Layer to let the users add a custom layer #21

Open
bnjjj opened this issue Aug 10, 2022 · 0 comments
Open

Add new variant in enum Layer to let the users add a custom layer #21

bnjjj opened this issue Aug 10, 2022 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@bnjjj
Copy link
Owner

bnjjj commented Aug 10, 2022

Add that kind of variant in Layer.

// the custom variant
Custom(Box<dyn Fn() -> Result<serde_json::Value, twelf::Error>>)

which would let us use this layer like this

let fetch_from_api = || {
    let res= reqwest::blocking::get(« http://myapi.com »).unwrap();
    res
};
Conf::with_layers(&[Layer::Env(None), Layer::Custom(Box::new(&fetch_from_api)]).unwrap();

the main goal is to let users fetch part of the configuration from whatever they want and not only from provided and supporter layers

@bnjjj bnjjj added enhancement New feature or request good first issue Good for newcomers labels Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant