httpcache

package
v0.0.0-...-7c2d22d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package httpcache provides an interface to HTTP request static cache,

Usage example :

func main() {
  url := "https://api.github.com/repos/astaxie/beego/contributors"
  body := httpcache.MakeCachedHTTPRequest(url)
  jsonResp, linkHeader, _ := httpcache.ReadResp(body)
  fmt.Printf("%s\n%s", jsonResp, linkHeader)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFilename

func GetFilename(url string) string

GetFilename gets encoded filename for cache usage

func MakeCachedHTTPRequest

func MakeCachedHTTPRequest(url string, tmpFolder string, debug bool) []byte

MakeCachedHTTPRequest makes a cacheable request to the external URL If the request was already made once, it will be not done again, but read from the file in temporary folder. Currently is was tested only for GET queries

func MakeHTTPRequest

func MakeHTTPRequest(url string) ([]byte, int, error)

MakeHTTPRequest makes a non-cacheable request to the external URL

func ReadResp

func ReadResp(fullResp []byte) ([]byte, string, error)

ReadResp : reads response from the cached HTTP query.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL