Skip to content

Commit

Permalink
refactor: simplify project
Browse files Browse the repository at this point in the history
  • Loading branch information
aofei committed May 23, 2019
1 parent 5bb258a commit 7af160b
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 38 deletions.
2 changes: 0 additions & 2 deletions config.toml
Expand Up @@ -5,8 +5,6 @@ debug_mode = true
address = "localhost:8080"
minifier_enabled = true
gzip_enabled = true
coffer_enabled = true
i18n_enabled = true

# Zerolog
[zerolog]
Expand Down
2 changes: 1 addition & 1 deletion goproxy.cn.service
@@ -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]
Expand Down
20 changes: 12 additions & 8 deletions handlers/handlers.go
Expand Up @@ -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,
Expand All @@ -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 {
Expand Down
3 changes: 0 additions & 3 deletions locales/en-US.toml

This file was deleted.

3 changes: 0 additions & 3 deletions locales/zh-CN.toml

This file was deleted.

2 changes: 0 additions & 2 deletions robots.txt

This file was deleted.

19 changes: 0 additions & 19 deletions templates/index.html

This file was deleted.

0 comments on commit 7af160b

Please sign in to comment.