add comments
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user