package config

import (
	"os"
)

type Config struct {
	Debug          bool
	ListenAddress  string
	Key            string
	IPV6           bool
	RequestTimeout uint
	FollowRedirect bool
	MaxConnsPerHost uint
	UrlParameter string
	HashParameter string
}

var DefaultConfig *Config

func init() {
	default_listen_addr := os.Getenv("YUKARI_ADDRESS")
	if default_listen_addr == "" {
		default_listen_addr = "127.0.0.1:3000"
	}
	default_url_parameter := os.Getenv("YUKARI_URL_PARAM")
	if default_url_parameter == "" {
		default_url_parameter = "yukariurl"
	}
	default_hash_parameter := os.Getenv("YUKARI_HASH_PARAM")
	if default_hash_parameter == "" {
		default_hash_parameter = "yukarihash"
	}
	default_key := os.Getenv("YUKARI_KEY")
	DefaultConfig = &Config{
		Debug:          os.Getenv("DEBUG") != "false",
		ListenAddress:  default_listen_addr,
		Key:            default_key,
		IPV6:           true,
		RequestTimeout: 5,
		FollowRedirect: false,
		MaxConnsPerHost: 4,
		UrlParameter: default_url_parameter,
		HashParameter: default_hash_parameter,
	}
}
