wallet/pkg/rest/sync_middleware.go
Anton Nesterov b19bf34e5f
[init]
2024-08-31 16:54:43 +02:00

31 lines
558 B
Go

package rest
import (
"fmt"
"net/http"
"github.com/gin-gonic/gin"
)
var syncState bool = false
func SyncMiddleware() gin.HandlerFunc {
return func(c *gin.Context) {
qs := c.Request.URL.Query()
for key, values := range qs {
fmt.Printf("key = %v, value(s) = %v\n", key, values)
if key == "sync_state" {
if values[0] == "true" {
syncState = true
} else {
syncState = false
}
}
}
if syncState {
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"error": "sync state"})
return
}
c.Next()
}
}