Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cd4bc63

Browse files
committed
修复 HEAD 请求 dl 的 bug
1 parent 8ee213c commit cd4bc63

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

http/controller/download.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type DownloadController struct{}
2828
// 注册路由
2929
func (self DownloadController) RegisterRoute(g *echo.Group) {
3030
g.GET("/dl", self.GoDl)
31-
g.GET("/dl/golang/:filename", self.FetchGoInstallPackage)
31+
g.Match([]string{"GET", "HEAD"}, "/dl/golang/:filename", self.FetchGoInstallPackage)
3232
g.GET("/dl/add_new_version", self.AddNewDownload)
3333
}
3434

http/middleware/http_error.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
echo "github.com/labstack/echo/v4"
1616
)
1717

18-
// EchoLogger 用于 echo 框架的日志中间件
18+
// HTTPError 用于 echo 框架的 HTTP 错误
1919
func HTTPError() echo.MiddlewareFunc {
2020
return func(next echo.HandlerFunc) echo.HandlerFunc {
2121
return func(ctx echo.Context) error {
@@ -39,6 +39,8 @@ func HTTPError() echo.MiddlewareFunc {
3939
return ctx.String(http.StatusOK, `{"ok":0,"error":"接口服务器错误"}`)
4040
}
4141
return Render(ctx, "500.html", nil)
42+
default:
43+
return err
4244
}
4345
}
4446
}

0 commit comments

Comments
 (0)