wallet/pkg/rest/sync_middleware.go
Anton Nesterov 5efcf35dd6
[init]
2024-08-31 16:59:34 +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()
}
}