You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I'm using Go template in Knative Functions. Since there's only a Handle function to handle income requests, is there any recommendation about application initialization?
For example, we need to load some secret from the environment:
// handle.go
var (
token string
)
func init {
token := os.Getenv("SOME_API_TOKEN")
if(token == "") {
panic("API TOKEN not configured")
}
}
func Handle() {
// result = DoRequest(token)
// return result
}
However, it seems that use init to load environment is not a good approach, it's not test friendly anyway, see here.
So the problems is that, how to correctly add additional initialization steps?
The text was updated successfully, but these errors were encountered:
Hi,
I'm using Go template in Knative Functions. Since there's only a
Handle
function to handle income requests, is there any recommendation about application initialization?For example, we need to load some secret from the environment:
However, it seems that use
init
to load environment is not a good approach, it's not test friendly anyway, see here.So the problems is that, how to correctly add additional initialization steps?
The text was updated successfully, but these errors were encountered: