mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 17:24:26 +08:00
add comments
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/mayswind/lab/pkg/utils"
|
"github.com/mayswind/lab/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// JWTAuthorization verifies whether current request is valid by jwt token
|
||||||
func JWTAuthorization(c *core.Context) {
|
func JWTAuthorization(c *core.Context) {
|
||||||
claims, err := getTokenClaims(c)
|
claims, err := getTokenClaims(c)
|
||||||
|
|
||||||
@@ -34,6 +35,7 @@ func JWTAuthorization(c *core.Context) {
|
|||||||
c.Next()
|
c.Next()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// JWTTwoFactorAuthorization verifies whether current request is valid by 2fa passcode
|
||||||
func JWTTwoFactorAuthorization(c *core.Context) {
|
func JWTTwoFactorAuthorization(c *core.Context) {
|
||||||
claims, err := getTokenClaims(c)
|
claims, err := getTokenClaims(c)
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ var (
|
|||||||
slash = []byte("/")
|
slash = []byte("/")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Recovery logs error message when error occurs
|
||||||
func Recovery(c *core.Context) {
|
func Recovery(c *core.Context) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
const requestIdHeader = "X-Request-ID"
|
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 {
|
func RequestId(config *settings.Config) core.MiddlewareHandlerFunc {
|
||||||
return func(c *core.Context) {
|
return func(c *core.Context) {
|
||||||
if requestid.Container.Current == nil {
|
if requestid.Container.Current == nil {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/mayswind/lab/pkg/log"
|
"github.com/mayswind/lab/pkg/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// RequestLog logs the http request log
|
||||||
func RequestLog(c *core.Context) {
|
func RequestLog(c *core.Context) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
path := c.Request.URL.Path
|
path := c.Request.URL.Path
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
|
|
||||||
const settingsCookieName = "ACP_SETTINGS"
|
const settingsCookieName = "ACP_SETTINGS"
|
||||||
|
|
||||||
|
// ServerSettingsCookie adds server settings to cookies in response
|
||||||
func ServerSettingsCookie(config *settings.Config) core.MiddlewareHandlerFunc {
|
func ServerSettingsCookie(config *settings.Config) core.MiddlewareHandlerFunc {
|
||||||
return func(c *core.Context) {
|
return func(c *core.Context) {
|
||||||
settingsArr := []string{
|
settingsArr := []string{
|
||||||
|
|||||||
Reference in New Issue
Block a user