Closed valentinegb closed 1 year ago
This doesn't quite work actually, because the key needs to be known at compile-time, and set_key
would always execute at run-time.
Well, unless someone can figure out a way to define a key pre-compile-time without relying on an environment variable, I'm closing this as not planned. It really would be nice, but not nice enough to sacrifice automation of the ModelID
enumerator.
Problem
Sometimes, for whatever the reason may be, a developer may opt to not use an environment variable for authentication. Currently, this is impossible.
Solution
I'm thinking of a function something like
set_key(key: &str)
that stores thekey
attribute in a variable in the library that can only be read within the library. Then, using an environment variable for the API key would look something like this:Alternatives
There could just be a
key
variable in the library that is able to be read and changed from wherever, but that doesn't sound very safe to me.