重构项目的实现,优化使用方法与使用逻辑
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"git.toowon.com/jimmy/go-common/middleware"
|
||||
"git.toowon.com/jimmy/go-common/requestctx"
|
||||
"git.toowon.com/jimmy/go-common/tools"
|
||||
)
|
||||
|
||||
@@ -97,18 +97,12 @@ func ParseJSON(r *http.Request, v interface{}) error {
|
||||
return json.Unmarshal(body, v)
|
||||
}
|
||||
|
||||
// GetTimezone 从请求的context中获取时区(公共方法)
|
||||
// r: HTTP请求
|
||||
// 如果使用了middleware.Timezone中间件,可以从context中获取时区信息
|
||||
// 如果未设置,返回默认时区 AsiaShanghai
|
||||
// GetTimezone 从请求的 context 中获取时区
|
||||
func GetTimezone(r *http.Request) string {
|
||||
return middleware.GetTimezoneFromContext(r.Context())
|
||||
return requestctx.Timezone(r.Context())
|
||||
}
|
||||
|
||||
// GetLanguage 从请求的context中获取语言(公共方法)
|
||||
// r: HTTP请求
|
||||
// 如果使用了middleware.Language中间件,可以从context中获取语言信息
|
||||
// 如果未设置,返回默认语言 zh-CN
|
||||
// GetLanguage 从请求的 context 中获取语言
|
||||
func GetLanguage(r *http.Request) string {
|
||||
return middleware.GetLanguageFromContext(r.Context())
|
||||
return requestctx.Language(r.Context())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user