mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-10-28 20:55:42 +00:00
* refactor: rework decoders logic for cleaner code * refactor: use strcase lib to handle text case conversions
20 lines
356 B
Go
20 lines
356 B
Go
package decoders
|
|
|
|
import (
|
|
"github.com/traefik/paerser/parser"
|
|
)
|
|
|
|
func DecodeEnv[T any, C any](env map[string]string, subName string) (T, error) {
|
|
var result T
|
|
|
|
normalized := normalizeKeys[C](env, subName, "_")
|
|
|
|
err := parser.Decode(normalized, &result, "tinyauth", "tinyauth."+subName)
|
|
|
|
if err != nil {
|
|
return result, err
|
|
}
|
|
|
|
return result, nil
|
|
}
|