mirror of
https://github.com/imgproxy/imgproxy.git
synced 2024-11-18 16:31:44 +02:00
Normalize IMGPROXY_PATH_PREFIX and IMGPROXY_HEALTH_CHECK_PATH
This commit is contained in:
parent
aad0186b0a
commit
aaaf1c706d
@ -406,7 +406,7 @@ func Configure() error {
|
||||
|
||||
configurators.Bool(&SoReuseport, "IMGPROXY_SO_REUSEPORT")
|
||||
|
||||
configurators.String(&PathPrefix, "IMGPROXY_PATH_PREFIX")
|
||||
configurators.URLPath(&PathPrefix, "IMGPROXY_PATH_PREFIX")
|
||||
|
||||
configurators.MegaInt(&MaxSrcResolution, "IMGPROXY_MAX_SRC_RESOLUTION")
|
||||
configurators.Int(&MaxSrcFileSize, "IMGPROXY_MAX_SRC_FILE_SIZE")
|
||||
@ -449,7 +449,7 @@ func Configure() error {
|
||||
configurators.Bool(&EnforceAvif, "IMGPROXY_ENFORCE_AVIF")
|
||||
configurators.Bool(&EnableClientHints, "IMGPROXY_ENABLE_CLIENT_HINTS")
|
||||
|
||||
configurators.String(&HealthCheckPath, "IMGPROXY_HEALTH_CHECK_PATH")
|
||||
configurators.URLPath(&HealthCheckPath, "IMGPROXY_HEALTH_CHECK_PATH")
|
||||
|
||||
if err := configurators.ImageTypes(&PreferredFormats, "IMGPROXY_PREFERRED_FORMATS"); err != nil {
|
||||
return err
|
||||
|
@ -102,6 +102,25 @@ func Bool(b *bool, name string) {
|
||||
}
|
||||
}
|
||||
|
||||
func URLPath(s *string, name string) {
|
||||
if env := os.Getenv(name); len(env) > 0 {
|
||||
if i := strings.IndexByte(env, '?'); i >= 0 {
|
||||
env = env[:i]
|
||||
}
|
||||
if i := strings.IndexByte(env, '#'); i >= 0 {
|
||||
env = env[:i]
|
||||
}
|
||||
if len(env) > 0 && env[len(env)-1] == '/' {
|
||||
env = env[:len(env)-1]
|
||||
}
|
||||
if len(env) > 0 && env[0] != '/' {
|
||||
env = "/" + env
|
||||
}
|
||||
|
||||
*s = env
|
||||
}
|
||||
}
|
||||
|
||||
func ImageTypes(it *[]imagetype.Type, name string) error {
|
||||
if env := os.Getenv(name); len(env) > 0 {
|
||||
parts := strings.Split(env, ",")
|
||||
|
@ -19,7 +19,7 @@ func healthcheck() int {
|
||||
|
||||
configurators.String(&network, "IMGPROXY_NETWORK")
|
||||
configurators.String(&bind, "IMGPROXY_BIND")
|
||||
configurators.String(&pathprefix, "IMGPROXY_PATH_PREFIX")
|
||||
configurators.URLPath(&pathprefix, "IMGPROXY_PATH_PREFIX")
|
||||
|
||||
httpc := http.Client{
|
||||
Transport: &http.Transport{
|
||||
|
Loading…
Reference in New Issue
Block a user