Giter Site home page Giter Site logo

contentful-go's People

Contributors

erdemtoraman avatar janivihervas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jasperlabs

contentful-go's Issues

Add cache capability

It would be used in search function: https://github.com/janivihervas/contentful-go/blob/master/search.go#L128

Interface could look something like this:

type CacheEntry struct {
	URL string
	JSON []byte
	ETag string
}

type Cache interface {
	Get(ctx context.Context, url string) (CacheEntry, error)
	Save(ctx context.Context, entry CacheEntry) error
}

Request handling:
If an entry is in cache, supply the etag in If-None-Match header

Response handling:
If cache implementation is not supplied to constructor, response with non-200 status code would still fail. If cache is supplied, 200 status code would Save the result and 304 status code would serve it from cache.

Requires a new extensible constructor function to prevent breaking changes.

Requires a cache pruning functionality, as Contentful web hooks only specify the entry id that was modified, and cache keys will in most cases be search queries instead of searching by id

Document external urls

Document the external urls that the SDK will use, so they can be allowed explicitly in strict environments like Istio

Allow to supply a custom http.Client

Implementation is using http.DefaultClient. Implement a functionality to provide a custom http.Client to provide e.g. OpenCensus capability.

In order to keep backwards-compatibility, either export the client field or set it with a method like

cms := contentful.New(...)
cms.WithHttpClient(&http.Client{...})

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.