add comments

This commit is contained in:
MaysWind
2020-12-26 00:15:05 +08:00
parent 823ed89612
commit 922582d60d
5 changed files with 6 additions and 0 deletions
+2
View File
@@ -10,6 +10,7 @@ import (
"github.com/mayswind/lab/pkg/utils"
)
// JWTAuthorization verifies whether current request is valid by jwt token
func JWTAuthorization(c *core.Context) {
claims, err := getTokenClaims(c)
@@ -34,6 +35,7 @@ func JWTAuthorization(c *core.Context) {
c.Next()
}
// JWTTwoFactorAuthorization verifies whether current request is valid by 2fa passcode
func JWTTwoFactorAuthorization(c *core.Context) {
claims, err := getTokenClaims(c)
+1
View File
@@ -19,6 +19,7 @@ var (
slash = []byte("/")
)
// Recovery logs error message when error occurs
func Recovery(c *core.Context) {
defer func() {
if err := recover(); err != nil {
+1
View File
@@ -8,6 +8,7 @@ import (
const requestIdHeader = "X-Request-ID"
// RequestId generates a new request id and add it to context and response header
func RequestId(config *settings.Config) core.MiddlewareHandlerFunc {
return func(c *core.Context) {
if requestid.Container.Current == nil {
+1
View File
@@ -7,6 +7,7 @@ import (
"github.com/mayswind/lab/pkg/log"
)
// RequestLog logs the http request log
func RequestLog(c *core.Context) {
start := time.Now()
path := c.Request.URL.Path
@@ -10,6 +10,7 @@ import (
const settingsCookieName = "ACP_SETTINGS"
// ServerSettingsCookie adds server settings to cookies in response
func ServerSettingsCookie(config *settings.Config) core.MiddlewareHandlerFunc {
return func(c *core.Context) {
settingsArr := []string{