Skip to content

Commit

Permalink
refactor(config): change KIMG_HTTPD_HOST to KIMG_HTTPD_URL
Browse files Browse the repository at this point in the history
BREAKING CHANGE: KIMG_HTTPD_HOST changed to KIMG_HTTPD_URL
  • Loading branch information
zhoukk committed Jun 4, 2019
1 parent 664a3ba commit 3546341
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
type KimgConfig struct {
Httpd struct {
Bind string `yaml:"bind,omitempty"`
Host string `yaml:"host,omitempty"`
URL string `yaml:"url,omitempty"`
Headers map[string]string `yaml:"headers,omitempty"`
Etag bool `yaml:"etag,omitempty"`
MaxAge int `yaml:"maxAge,omitempty"`
Expand Down Expand Up @@ -62,7 +62,7 @@ func NewKimgConfig(configFile string) (*KimgConfig, error) {
var cfg KimgConfig

cfg.Httpd.Bind = "0.0.0.0:80"
cfg.Httpd.Host = "/"
cfg.Httpd.URL = "/"
cfg.Httpd.Headers = map[string]string{"Server": "kimg"}
cfg.Httpd.Etag = true
cfg.Httpd.MaxAge = 90 * 24 * 3600
Expand Down Expand Up @@ -105,8 +105,8 @@ func NewKimgConfig(configFile string) (*KimgConfig, error) {
if env, ok := os.LookupEnv("KIMG_HTTPD_BIND"); ok {
cfg.Httpd.Bind = env
}
if env, ok := os.LookupEnv("KIMG_HTTPD_HOST"); ok {
cfg.Httpd.Host = env
if env, ok := os.LookupEnv("KIMG_HTTPD_URL"); ok {
cfg.Httpd.URL = env
}
if env, ok := os.LookupEnv("KIMG_HTTPD_HEADERS"); ok {
arr := strings.Split(env, ",")
Expand Down
2 changes: 1 addition & 1 deletion image.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (image *KimgImagick) Info(req *KimgRequest, data []byte) (*KimgResponse, er
exif[name] = mw.GetImageProperty(name)
}

u, _ := url.Parse(image.ctx.Config.Httpd.Host)
u, _ := url.Parse(image.ctx.Config.Httpd.URL)
u.Path = fmt.Sprintf("image/%s", req.Md5)
return &KimgResponse{
Md5: req.Md5,
Expand Down
6 changes: 3 additions & 3 deletions kimg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ httpd:
# ENV KIMG_HTTPD_BIND
bind: 0.0.0.0:80

# Kimg web server hostname to serve.
# Kimg web server url.
#
# ENV KIMG_HTTPD_HOST
host:
# ENV KIMG_HTTPD_URL
url:

# Http headers set on image fetch response.
#
Expand Down

0 comments on commit 3546341

Please sign in to comment.