Allow http plugin to cache responses (#10218)
This commit is contained in:
parent
eed082b171
commit
a467a79475
3 changed files with 9 additions and 0 deletions
1
go.mod
1
go.mod
|
|
@ -43,6 +43,7 @@ require (
|
|||
github.com/gorilla/handlers v1.5.1
|
||||
github.com/gorilla/mux v1.8.0
|
||||
github.com/gregdel/pushover v1.3.0
|
||||
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79
|
||||
github.com/grid-x/modbus v0.0.0-20230713135356-d9fefd3ae5a5
|
||||
github.com/hashicorp/go-version v1.6.0
|
||||
github.com/hasura/go-graphql-client v0.10.0
|
||||
|
|
|
|||
2
go.sum
2
go.sum
|
|
@ -397,6 +397,8 @@ github.com/graph-gophers/graphql-transport-ws v0.0.2 h1:DbmSkbIGzj8SvHei6n8Mh9eL
|
|||
github.com/graph-gophers/graphql-transport-ws v0.0.2/go.mod h1:5BVKvFzOd2BalVIBFfnfmHjpJi/MZ5rOj8G55mXvZ8g=
|
||||
github.com/gregdel/pushover v1.3.0 h1:CewbxqsThoN/1imgwkDKFkRkltaQMoyBV0K9IquQLtw=
|
||||
github.com/gregdel/pushover v1.3.0/go.mod h1:EcaO66Nn1StkpEm1iKtBTV3d2A16SoMsVER1PthX7to=
|
||||
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJrOjhax5N+uePQ0Fh1Z7PheYoUI/0nzkPA=
|
||||
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
|
||||
github.com/grid-x/serial v0.0.0-20191104121038-e24bc9bf6f08/go.mod h1:kdOd86/VGFWRrtkNwf1MPk0u1gIjc4Y7R2j7nhwc7Rk=
|
||||
github.com/grid-x/serial v0.0.0-20211107191517-583c7356b3aa h1:Rsn6ARgNkXrsXJIzhkE4vQr5Gbx2LvtEMv4BJOK4LyU=
|
||||
github.com/grid-x/serial v0.0.0-20211107191517-583c7356b3aa/go.mod h1:kdOd86/VGFWRrtkNwf1MPk0u1gIjc4Y7R2j7nhwc7Rk=
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import (
|
|||
"github.com/evcc-io/evcc/util"
|
||||
"github.com/evcc-io/evcc/util/request"
|
||||
"github.com/evcc-io/evcc/util/transport"
|
||||
"github.com/gregjones/httpcache"
|
||||
"github.com/jpfielding/go-http-digest/pkg/digest"
|
||||
)
|
||||
|
||||
|
|
@ -103,6 +104,11 @@ func NewHTTP(log *util.Logger, method, uri string, insecure bool, scale float64,
|
|||
cache: cache,
|
||||
}
|
||||
|
||||
// http cache
|
||||
cacheTransport := httpcache.NewMemoryCacheTransport()
|
||||
cacheTransport.Transport = p.Client.Transport
|
||||
p.Client.Transport = cacheTransport
|
||||
|
||||
// ignore the self signed certificate
|
||||
if insecure {
|
||||
p.Client.Transport = request.NewTripper(log, transport.Insecure())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue