0
Fork 0
mirror of https://github.com/willnorris/imageproxy.git synced 2024-12-16 21:56:43 -05:00

use gorilla/mux for routing requests

Thanks to @Fieldistor for the reminder that gorilla/mux allows you to
disable cleaning request URLs, which was causing problems with signature
verification for some URLs.

Fixes #215
Fixes #212
This commit is contained in:
Will Norris 2020-04-02 22:29:10 +00:00
parent 00652fd9cb
commit 3589510f2c
3 changed files with 6 additions and 2 deletions

View file

@ -31,6 +31,7 @@ import (
"github.com/die-net/lrucache"
"github.com/die-net/lrucache/twotier"
"github.com/garyburd/redigo/redis"
"github.com/gorilla/mux"
"github.com/gregjones/httpcache/diskcache"
rediscache "github.com/gregjones/httpcache/redis"
"github.com/jamiealquiza/envy"
@ -99,9 +100,10 @@ func main() {
Handler: p,
}
r := mux.NewRouter().SkipClean(true).UseEncodedPath()
r.PathPrefix("/").Handler(p)
fmt.Printf("imageproxy listening on %s\n", server.Addr)
http.Handle("/", p)
log.Fatal(http.ListenAndServe(*addr, nil))
log.Fatal(http.ListenAndServe(*addr, r))
}
type signatureKeyList [][]byte

1
go.mod
View file

@ -14,6 +14,7 @@ require (
github.com/garyburd/redigo v1.6.0
github.com/gomodule/redigo v2.0.0+incompatible // indirect
github.com/google/btree v1.0.0 // indirect
github.com/gorilla/mux v1.6.2
github.com/gregjones/httpcache v0.0.0-20190212212710-3befbb6ad0cc
github.com/grpc-ecosystem/grpc-gateway v1.8.5 // indirect
github.com/hashicorp/golang-lru v0.5.1 // indirect

1
go.sum
View file

@ -94,6 +94,7 @@ github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk
github.com/googleapis/gax-go/v2 v2.0.4 h1:hU4mGcQI4DaAYW+IbTun+2qEZVFxK0ySjQLTbS0VQKc=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
github.com/gorilla/mux v1.6.2 h1:Pgr17XVTNXAk3q/r4CpKzC5xBM/qW1uVLV+IhRZpIIk=
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
github.com/gregjones/httpcache v0.0.0-20190212212710-3befbb6ad0cc h1:f8eY6cV/x1x+HLjOp4r72s/31/V2aTUtg5oKRRPf8/Q=