mirror of
https://github.com/willnorris/imageproxy.git
synced 2024-12-30 22:34:18 -05:00
add cacheDir for specifying disk cache dir
This commit is contained in:
parent
73f6357cda
commit
1db6456329
1 changed files with 9 additions and 1 deletions
|
@ -22,18 +22,26 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/gregjones/httpcache"
|
"github.com/gregjones/httpcache"
|
||||||
|
"github.com/gregjones/httpcache/diskcache"
|
||||||
"github.com/willnorris/go-imageproxy/proxy"
|
"github.com/willnorris/go-imageproxy/proxy"
|
||||||
)
|
)
|
||||||
|
|
||||||
var addr = flag.String("addr", "localhost:8080", "TCP address to listen on")
|
var addr = flag.String("addr", "localhost:8080", "TCP address to listen on")
|
||||||
var whitelist = flag.String("whitelist", "", "comma separated list of allowed remote hosts")
|
var whitelist = flag.String("whitelist", "", "comma separated list of allowed remote hosts")
|
||||||
|
var cacheDir = flag.String("cacheDir", "", "directory to use for file cache")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
fmt.Printf("go-imageproxy listening on %s\n", *addr)
|
fmt.Printf("go-imageproxy listening on %s\n", *addr)
|
||||||
|
|
||||||
c := httpcache.NewMemoryCache()
|
var c httpcache.Cache
|
||||||
|
if *cacheDir != "" {
|
||||||
|
c = diskcache.New(*cacheDir)
|
||||||
|
} else {
|
||||||
|
c = httpcache.NewMemoryCache()
|
||||||
|
}
|
||||||
|
|
||||||
p := proxy.NewProxy(nil, c)
|
p := proxy.NewProxy(nil, c)
|
||||||
p.MaxWidth = 2000
|
p.MaxWidth = 2000
|
||||||
p.MaxHeight = 2000
|
p.MaxHeight = 2000
|
||||||
|
|
Loading…
Reference in a new issue