httpcache
所属分类:WEB开发
开发工具:GO
文件大小:16KB
下载次数:0
上传日期:2018-12-06 11:58:33
上 传 者:
sh-1993
说明: 将所有请求代理到其他HTTP服务器的HTTP服务器,并且该服务器缓存所有传入响应对象
(An HTTP server that proxies all requests to other HTTP servers and this servers caches all incoming responses objects)
文件列表:
.travis.yml (200, 2018-12-06)
Dockerfile (573, 2018-12-06)
LICENSE (1077, 2018-12-06)
cmd (0, 2018-12-06)
cmd\httpcache (0, 2018-12-06)
cmd\httpcache\main.go (3313, 2018-12-06)
internal (0, 2018-12-06)
internal\cache (0, 2018-12-06)
internal\cache\cache.go (5971, 2018-12-06)
internal\handler (0, 2018-12-06)
internal\handler\ping.go (344, 2018-12-06)
internal\handler\proxycache.go (3101, 2018-12-06)
internal\handler\stats.go (1053, 2018-12-06)
internal\middleware (0, 2018-12-06)
internal\middleware\panic.go (991, 2018-12-06)
internal\middleware\panic_test.go (389, 2018-12-06)
internal\roundtripper (0, 2018-12-06)
internal\roundtripper\cacher.go (1318, 2018-12-06)
internal\roundtripper\cacher_test.go (528, 2018-12-06)
internal\roundtripper\logger.go (658, 2018-12-06)
internal\roundtripper\reponse_body_limit.go (550, 2018-12-06)
internal\size (0, 2018-12-06)
internal\size\size.go (133, 2018-12-06)
internal\xhttp (0, 2018-12-06)
internal\xhttp\server.go (1071, 2018-12-06)
tests (0, 2018-12-06)
tests\api_test.go (12192, 2018-12-06)
# httpcache
[![Build Status](https://travis-ci.org/donutloop/httpcache.svg?branch=master)](https://travis-ci.org/donutloop/httpcache)
[![Coverage Status](https://coveralls.io/repos/github/donutloop/httpcache/badge.svg)](https://coveralls.io/github/donutloop/httpcache)
An HTTP server that proxies all requests to other HTTP servers and this servers caches all incoming responses objects
## Backend Requirements
* [golang](https://golang.org/) - The Go Programming Language
* [docker](https://www.docker.com/) - Build, Manage and Secure Your Apps Anywhere. Your Way.
## Prepare GO development environment
Follow [install guide](https://golang.org/doc/install) to install golang.
## Build without docker
```bash
mkdir -p $GOPATH/src/github.com/donutloop/ && cd $GOPATH/src/github.com/donutloop/
git clone git@github.com:donutloop/httpcache.git
cd httpcache
go build ./cmd/httpcache
```
## Build with docker
```bash
mkdir -p $GOPATH/src/github.com/donutloop/ && cd $GOPATH/src/github.com/donutloop/
git clone git@github.com:donutloop/httpcache.git
docker build .
```
## Usage
```bash
USAGE
httpcache [flags]
FLAGS
-cap 100 capacity of cache
-cert server.crt TLS certificate
-expire 5 the items in the cache expire after or expire never
-http :80 serve HTTP on this address (optional)
-key server.key TLS key
-rbcl 524288000 response size limit
-tls serve TLS on this address (optional)
```
## Usage of cache from outside (GO Example)
```golang
...
transport := &http.Transport{
Proxy: SetProxyURL(proxyServer.URL), // Set url of http cache
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
DualStack: true,
}).DialContext,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
}
client = &http.Client{
Transport: transport,
}
client.Do(req)
...
```
## Run container
It's expose port 8000 and run a spefici container by id
```bash
sudo docker run -p 8000:8000 {{container_id}}
```
近期下载者:
相关文件:
收藏者: