Skip to content
A cached http client for the KrakenD framework
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
Gopkg.lock deps ugraded Oct 30, 2018
Gopkg.toml
LICENSE
README.md initial commit Feb 20, 2018
http.go use the brand new transport package Oct 30, 2018
http_test.go

README.md

Krakend HTTP Cache

A cached http client for the KrakenD framework

Using it

This package exposes two simple factories capable to create a instances of the proxy.HTTPClientFactory and the proxy.BackendFactory interfaces, respectively, embedding an in-memory-cached http client using the package github.com/gregjones/httpcache. The client will cache the responses honoring the defined Cache HTTP header.

import 	(
	"context"
	"net/http"
	"github.com/devopsfaith/krakend/config"
	"github.com/devopsfaith/krakend/proxy"
	"github.com/devopsfaith/krakend-httpcache"
)

requestExecutorFactory := func(cfg *config.Backend) proxy.HTTPRequestExecutor {
	clientFactory := httpcache.NewHTTPClient(cfg)
	return func(ctx context.Context, req *http.Request) (*http.Response, error) {
		return clientFactory(ctx).Do(req.WithContext(ctx))
	}
}

You can create your own proxy.HTTPRequestExecutor and inject it into your BackendFactory

You can’t perform that action at this time.