Documentation ¶
Index ¶
- Variables
- func AllObjectToRequest(o []*js.Object) []cache.Request
- func AllObjectToResponse(o []*js.Object) []cache.Response
- func MapToHeaders(res map[string]string) *js.Object
- func ObjectToList(o *js.Object) []*js.Object
- func ObjectToMap(o *js.Object) map[string]string
- func ObjectToRequest(o *js.Object) (cache.Request, error)
- func ObjectToRequests(o *js.Object) []cache.Request
- func ObjectToResponse(o *js.Object) (cache.Response, error)
- func ObjectToStringList(o *js.Object) []string
- func RequestToJSRequest(res *cache.Request) *js.Object
- func ResponseToJSResponse(res *cache.Response) *js.Object
- type CacheAPI
- func (c *CacheAPI) Add(request string, resp *http.Response) error
- func (c *CacheAPI) AddAll(request ...string) error
- func (c *CacheAPI) AddData(path string, data []byte) error
- func (c *CacheAPI) All() ([]cache.WebPair, error)
- func (c *CacheAPI) Delete(request string) error
- func (c *CacheAPI) DeletePath(request string, attr map[string]interface{}) error
- func (c *CacheAPI) DeleteRequest(request cache.Request, attr map[string]interface{}) error
- func (c *CacheAPI) Empty() error
- func (c *CacheAPI) Get(request string) (cache.Request, cache.Response, error)
- func (c *CacheAPI) Keys(request interface{}, attr map[string]interface{}) ([]cache.Request, error)
- func (c *CacheAPI) Match(request cache.Request, attr map[string]interface{}) (cache.Response, error)
- func (c *CacheAPI) MatchAll(request cache.Request, attr map[string]interface{}) ([]cache.Response, error)
- func (c *CacheAPI) MatchAllPath(request string, attr map[string]interface{}) ([]cache.Response, error)
- func (c *CacheAPI) MatchPath(request string, attr map[string]interface{}) (cache.Response, error)
- func (c *CacheAPI) Put(request cache.Request, res cache.Response) error
- func (c *CacheAPI) Serve(w http.ResponseWriter, r *http.Request) error
Constants ¶
This section is empty.
Variables ¶
var ErrCacheNotFound = errors.New("Cache Not Found")
ErrCacheNotFound defines the error returned when the cached desired is not found.
var ErrInvalidState = errors.New("Cache Not Found")
ErrInvalidState is returned when the cache api does not exists in the global context.
var ErrRequestDoesNotExists = errors.New("Request not existing")
ErrRequestDoesNotExists is returned when the giving request does not exists in the catch.
Functions ¶
func AllObjectToRequest ¶
AllObjectToRequest returns a slice of WebResponses from a slice of js.Object.
func AllObjectToResponse ¶
AllObjectToResponse returns a slice of WebResponses from a slice of js.Object.
func MapToHeaders ¶
MapToHeaders converts a map into a js.Headers structure.
func ObjectToList ¶
ObjectToList returns a map from a giving object.
func ObjectToMap ¶
ObjectToMap returns a map from a giving object.
func ObjectToRequest ¶
ObjectToRequest converts a object to a cache.Request.
func ObjectToRequests ¶
ObjectToRequests returns a list of cache.Request objects from the provided object.
func ObjectToResponse ¶
ObjectToResponse converts a object to a cache.Response.
func ObjectToStringList ¶
ObjectToStringList returns a map from a giving object.
func RequestToJSRequest ¶
RequestToJSRequest converts a object to a js.Request.
Types ¶
type CacheAPI ¶
CacheAPI defines individual cache item received from a call to the internal cache API.
func New ¶
New returns a new instance of the CacheAPI using the browsers cache API. API found in webkit browsers. https://developer.mozilla.org/en-US/docs/Web/API/Cache.
func NewCacheAPI ¶
NewCacheAPI returns a new instance of the CacheAPI.
func (*CacheAPI) AddAll ¶
AddAll calls the internal caches.Cache.Add and caches.Cache.AddAll function matching against the request string/strings.
func (*CacheAPI) All ¶
All returns all the pairs of requests which have been added into the cache in the order they were added.
func (*CacheAPI) DeletePath ¶
DeletePath deletes the given path from the cache if found.
func (*CacheAPI) DeleteRequest ¶
DeleteRequest calls the internal caches.Cache.Delete function matching against the request for a js.Cache.Delete.
func (*CacheAPI) Keys ¶
Keys returns a slice of all cache keys for all request added in the order they were added.
func (*CacheAPI) Match ¶
func (c *CacheAPI) Match(request cache.Request, attr map[string]interface{}) (cache.Response, error)
Match calls the internal caches.Cache.Match function matching against the request string for a js.Cache.Match.
func (*CacheAPI) MatchAll ¶
func (c *CacheAPI) MatchAll(request cache.Request, attr map[string]interface{}) ([]cache.Response, error)
MatchAll calls the internal caches.Cache.MatchAll function matching against the request string for a js.Cache.Match.
func (*CacheAPI) MatchAllPath ¶
func (c *CacheAPI) MatchAllPath(request string, attr map[string]interface{}) ([]cache.Response, error)
MatchAllPath calls the internal caches.Cache.MatchAll function matching against the request string for a js.Cache.Match.
func (*CacheAPI) MatchPath ¶
MatchPath calls the internal caches.Cache.Match function matching against the request string.