From 5e763f1a8b5d0b66543813525301a0b9506c361a Mon Sep 17 00:00:00 2001 From: Curith Date: Thu, 21 Apr 2022 11:30:25 +0800 Subject: [PATCH] use const http status text instead of a variable (#921) --- src/webapi/config/i18n.go | 2 +- src/webapi/router/router.go | 2 -- src/webapi/router/router_login.go | 4 ++-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/webapi/config/i18n.go b/src/webapi/config/i18n.go index a24e58c1..64546bd4 100644 --- a/src/webapi/config/i18n.go +++ b/src/webapi/config/i18n.go @@ -4,7 +4,7 @@ var ( dict = map[string]string{ "just a test": "这只是一个测试", "just a test: %s": "这只是一个测试: %s", - "InternalServerError": "系统内部错误,请联系管理员", + "Internal Server Error": "系统内部错误,请联系管理员", "Username or password invalid": "登录失败,请检查用户名和密码", "Username is blank": "用户名不能为空", "Username has invalid characters": "用户名含有非法字符", diff --git a/src/webapi/router/router.go b/src/webapi/router/router.go index 57890bbb..387dfbf5 100644 --- a/src/webapi/router/router.go +++ b/src/webapi/router/router.go @@ -17,8 +17,6 @@ import ( promstat "github.com/didi/nightingale/v5/src/webapi/stat" ) -var InternalServerError = "InternalServerError" - func stat() gin.HandlerFunc { return func(c *gin.Context) { start := time.Now() diff --git a/src/webapi/router/router_login.go b/src/webapi/router/router_login.go index 379fabeb..bb04cc4b 100644 --- a/src/webapi/router/router_login.go +++ b/src/webapi/router/router_login.go @@ -68,7 +68,7 @@ func logoutPost(c *gin.Context) { delErr := deleteTokens(c.Request.Context(), metadata) if delErr != nil { - ginx.NewRender(c).Message(InternalServerError) + ginx.NewRender(c).Message(http.StatusText(http.StatusInternalServerError)) return } @@ -118,7 +118,7 @@ func refreshPost(c *gin.Context) { // Delete the previous Refresh Token err = deleteAuth(c.Request.Context(), refreshUuid) if err != nil { - ginx.NewRender(c, http.StatusUnauthorized).Message(InternalServerError) + ginx.NewRender(c, http.StatusUnauthorized).Message(http.StatusText(http.StatusInternalServerError)) return }