wallet/pkg/rest/sync_middleware.go
Anton Nesterov f1bc53ce2a
[init]
2024-08-31 17:00:14 +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()
}
}