diff --git a/s3imageserver/image.go b/s3imageserver/image.go index 2b123b7..c9cc7e6 100644 --- a/s3imageserver/image.go +++ b/s3imageserver/image.go @@ -15,6 +15,7 @@ import ( "github.com/kr/s3" ) +//Image ... type Image struct { Path string FileName string @@ -34,6 +35,7 @@ type Image struct { var allowedTypes = []string{".png", ".jpg", ".jpeg", ".gif", ".webp"} var allowedMap = map[vips.ImageType]string{vips.WEBP: ".webp", vips.JPEG: ".jpg", vips.PNG: ".png"} +//NewImage ... func NewImage(r *http.Request, config HandlerConfig, fileName string) (image *Image, err error) { maxDimension := 3064 height := int(to.Float64(r.URL.Query().Get("h"))) @@ -94,7 +96,8 @@ func (i *Image) getImage(w http.ResponseWriter, r *http.Request, AWSAccess strin err := i.getImageFromS3(AWSAccess, AWSSecret) if err != nil { fmt.Println(err) - err = i.getErrorImage() + errImage := i.getErrorImage() + fmt.Println(errImage) w.WriteHeader(404) } else { i.resizeCrop() diff --git a/s3imageserver/s3imageserver.go b/s3imageserver/s3imageserver.go index 2cd30aa..3bdd4dd 100644 --- a/s3imageserver/s3imageserver.go +++ b/s3imageserver/s3imageserver.go @@ -16,6 +16,7 @@ import ( "github.com/julienschmidt/httprouter" ) +//Config ... type Config struct { Handlers []HandlerConfig `json:"handlers"` HTTPPort int `json:"http_port"` @@ -26,6 +27,7 @@ type Config struct { HTTPSKey string `json:"https_key"` } +//HandlerConfig ... type HandlerConfig struct { Name string `json:"name"` Prefix string `json:"prefix"` @@ -42,8 +44,10 @@ type HandlerConfig struct { CacheTime *int `json:"cache_time"` } +//HandleVerification ... type HandleVerification func(string) bool +//Run ... func Run(verify HandleVerification) { envArg := flag.String("c", "config.json", "Configuration") flag.Parse()