Skip to content
Permalink
Browse files

refactor: serve basic files

  • Loading branch information...
aofei committed Aug 13, 2019
1 parent 915c0fc commit 06198349e1425a6117624df8ce1884da1c6b39e6
Showing with 33 additions and 10 deletions.
  1. BIN apple-touch-icon.png
  2. BIN assets/images/logo.jpg
  3. BIN favicon.ico
  4. +2 −1 go.mod
  5. +4 −2 go.sum
  6. +20 −7 handler/handler.go
  7. +7 −0 robots.txt
BIN +16.5 KB apple-touch-icon.png
Binary file not shown.
BIN +22.7 KB assets/images/logo.jpg
Binary file not shown.
BIN +15 KB favicon.ico
Binary file not shown.
3 go.mod
@@ -2,12 +2,13 @@ module github.com/goproxy/goproxy.cn

require (
github.com/BurntSushi/toml v0.3.1
github.com/air-gases/cacheman v0.7.4
github.com/air-gases/defibrillator v0.12.4
github.com/air-gases/limiter v0.12.4
github.com/air-gases/logger v0.12.4
github.com/air-gases/redirector v0.12.4
github.com/aofei/air v0.12.4
github.com/goproxy/goproxy v0.0.0-20190809144859-080f99010796
github.com/goproxy/goproxy v0.0.0-20190812143559-921935e9a7e6
github.com/mitchellh/mapstructure v1.1.2
github.com/rs/zerolog v1.14.3
)
6 go.sum
@@ -6,6 +6,8 @@ github.com/OneOfOne/xxhash v1.2.5/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdII
github.com/VictoriaMetrics/fastcache v1.5.1 h1:qHgHjyoNFV7jgucU8QZUuU4gcdhfs8QW1kw68OD2Lag=
github.com/VictoriaMetrics/fastcache v1.5.1/go.mod h1:+jv9Ckb+za/P1ZRg/sulP5Ni1v49daAVERr0H3CuscE=
github.com/a8m/mark v0.1.1-0.20170507133748-44f2db618845/go.mod h1:c8Mh99Cw82nrsAnPgxQSZHkswVOJF7/MqZb1ZdvriLM=
github.com/air-gases/cacheman v0.7.4 h1:YHPAHhTqM35p5e2wqmmPvOI8cH2qOrpd8vLJk10J2Wo=
github.com/air-gases/cacheman v0.7.4/go.mod h1:TJmesy/aTLt4S/pobyCsoL3YQxH2yqdnMolO+WNqmSU=
github.com/air-gases/defibrillator v0.12.4 h1:HF0f2sRiUgMjo/Zis7Qk5QGqWxQanqyZvMzorx/Ptfg=
github.com/air-gases/defibrillator v0.12.4/go.mod h1:aE/1W3C8pHIrA5UnCDOZc8GymWzmIMkM+GNauLIGDa4=
github.com/air-gases/limiter v0.12.4 h1:8fbuWeEbCw7Ge4NEu/JGJuSdDJu5i1r+BjSRR1KQNNg=
@@ -42,8 +44,8 @@ github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEW
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c h1:7lF+Vz0LqiRidnzC1Oq86fpX1q/iEv2KJdrCtttYjT4=
github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/goproxy/goproxy v0.0.0-20190809144859-080f99010796 h1:W+BJrnBAHlS2vKFBnEOWM3Qa+qgLDdfMaDHollJgc1A=
github.com/goproxy/goproxy v0.0.0-20190809144859-080f99010796/go.mod h1:rfiiqmbdu8wueRXcp96RTer4wRcBb23lUtdNghyaOas=
github.com/goproxy/goproxy v0.0.0-20190812143559-921935e9a7e6 h1:XnIh7jsnREGCHoDsiZnC8JEwrxoad72ATvimcW5B9QA=
github.com/goproxy/goproxy v0.0.0-20190812143559-921935e9a7e6/go.mod h1:rfiiqmbdu8wueRXcp96RTer4wRcBb23lUtdNghyaOas=
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
@@ -3,14 +3,27 @@ package handler
import (
"net/http"

"github.com/air-gases/cacheman"
"github.com/aofei/air"
"github.com/goproxy/goproxy"
"github.com/goproxy/goproxy.cn/cfg"
"github.com/goproxy/goproxy/cacher"
)

// a is the `air.Default`.
var a = air.Default
var (
// a is the `air.Default`.
a = air.Default

// getHeadMethods is an array contains the GET and the HEAD methods.
getHeadMethods = []string{http.MethodGet, http.MethodHead}

// cachemanGas is used to manage the Cache-Control header.
cachemanGas = cacheman.Gas(cacheman.GasConfig{
Public: true,
MaxAge: 3600,
SMaxAge: -1,
})
)

func init() {
g := goproxy.New()
@@ -24,11 +37,11 @@ func init() {

g.ErrorLogger = a.ErrorLogger

a.BATCH(
[]string{http.MethodGet, http.MethodHead},
"/",
indexPageHandler,
)
a.FILE("/robots.txt", "robots.txt")
a.FILE("/favicon.ico", "favicon.ico", cachemanGas)
a.FILE("/apple-touch-icon.png", "apple-touch-icon.png", cachemanGas)
a.FILES("/assets", a.CofferAssetRoot, cachemanGas)
a.BATCH(getHeadMethods, "/", indexPageHandler, cachemanGas)
a.BATCH(nil, "/*", air.WrapHTTPHandler(g))
}

@@ -0,0 +1,7 @@
User-Agent: *
Disallow: /*/@latest
Disallow: /*/@v/list
Disallow: /*/@v/*.info
Disallow: /*/@v/*.mod
Disallow: /*/@v/*.zip
Disallow: /sumdb/

0 comments on commit 0619834

Please sign in to comment.
You can’t perform that action at this time.