mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-03-01 01:20:49 +03:00
22 lines
324 B
Go
22 lines
324 B
Go
package middleware
|
|
|
|
import (
|
|
"net/http"
|
|
"strings"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func DomainValidatorMiddleware(domain string) gin.HandlerFunc {
|
|
return func(c *gin.Context) {
|
|
host := strings.Split(c.Request.Host, ":")[0]
|
|
|
|
if host != domain {
|
|
c.AbortWithStatus(http.StatusForbidden)
|
|
return
|
|
}
|
|
|
|
c.Next()
|
|
}
|
|
}
|