mirror of
				https://github.com/steveiliop56/tinyauth.git
				synced 2025-11-03 23:55:44 +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
 | 
						|
}
 |