fix: global lock middleware func signature

This commit is contained in:
Mohamed Sohail 2023-03-28 06:55:51 +00:00
parent 5f5678e25b
commit 750fdd9c1f
Signed by: kamikazechaser
GPG Key ID: 7DD45520C01CD85D

View File

@ -40,7 +40,7 @@ func initApiServer(custodialContainer *custodial.Custodial) *echo.Echo {
}) })
} }
apiRoute := server.Group("/api", systemGlobalLock) apiRoute := server.Group("/api", systemGlobalLock(custodialContainer))
apiRoute.POST("/account/create", api.HandleAccountCreate(custodialContainer)) apiRoute.POST("/account/create", api.HandleAccountCreate(custodialContainer))
apiRoute.GET("/account/status/:address", api.HandleNetworkAccountStatus(custodialContainer)) apiRoute.GET("/account/status/:address", api.HandleNetworkAccountStatus(custodialContainer))
@ -78,12 +78,9 @@ func customHTTPErrorHandler(err error, c echo.Context) {
}) })
} }
func systemGlobalLock(next echo.HandlerFunc) echo.HandlerFunc { func systemGlobalLock(cu *custodial.Custodial) echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error { return func(c echo.Context) error {
var (
cu = c.Get("cu").(*custodial.Custodial)
)
locked, err := cu.RedisClient.Get(c.Request().Context(), systemGlobalLockKey).Bool() locked, err := cu.RedisClient.Get(c.Request().Context(), systemGlobalLockKey).Bool()
if err != nil { if err != nil {
return err return err
@ -98,4 +95,5 @@ func systemGlobalLock(next echo.HandlerFunc) echo.HandlerFunc {
return next(c) return next(c)
} }
}
} }