Skip to content
Permalink
Browse files

refactor: simplify project

  • Loading branch information...
aofei committed May 23, 2019
1 parent 5bb258a commit 7af160b396309223ca38ae2e249e15116acc96e7
Showing with 13 additions and 38 deletions.
  1. +0 −2 config.toml
  2. +1 −1 goproxy.cn.service
  3. +12 −8 handlers/handlers.go
  4. +0 −3 locales/en-US.toml
  5. +0 −3 locales/zh-CN.toml
  6. +0 −2 robots.txt
  7. +0 −19 templates/index.html
@@ -5,8 +5,6 @@ debug_mode = true
address = "localhost:8080"
minifier_enabled = true
gzip_enabled = true
coffer_enabled = true
i18n_enabled = true

# Zerolog
[zerolog]
@@ -1,5 +1,5 @@
[Unit]
Description=A trusted Go module proxy located in China.
Description=The most trusted Go module proxy in China.
After=network.target

[Service]
@@ -92,12 +92,15 @@ func init() {
Msg("failed to set $GOSUMDB")
}

a.FILE("/robots.txt", "robots.txt")

a.BATCH(
[]string{http.MethodGet, http.MethodHead},
"/",
indexPageHandler,
)
a.BATCH(
[]string{http.MethodGet, http.MethodHead},
"/*",
mainHandler,
goproxyHandler,
cacheman.Gas(cacheman.GasConfig{
MustRevalidate: true,
NoCache: true,
@@ -108,12 +111,13 @@ func init() {
)
}

// mainHandler handles requests to perform a Go module proxy action.
func mainHandler(req *air.Request, res *air.Response) error {
if req.Path == "/" {
return res.Redirect("https://github.com/goproxy/goproxy.cn")
}
// indexPageHandler handles requests to get index page.
func indexPageHandler(req *air.Request, res *air.Response) error {
return res.Redirect("https://github.com/goproxy/goproxy.cn")
}

// goproxyHandler handles requests to perform a Go module proxy action.
func goproxyHandler(req *air.Request, res *air.Response) error {
filename := req.Param("*").Value().String()
filenameParts := strings.Split(filename, "/@")
if len(filenameParts) != 2 {

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 7af160b

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