Some checks failed
Release S-UI / build-frontend (push) Failing after 1m53s
Release S-UI / build-386 (push) Has been skipped
Release S-UI / build-amd64 (push) Has been skipped
Release S-UI / build-armv5 (push) Has been skipped
Release S-UI / build-armv6 (push) Has been skipped
Release S-UI / build-armv7 (push) Has been skipped
Release S-UI / build-s390x (push) Has been skipped
Release S-UI / build-arm64 (push) Has been skipped
Build S-UI for Windows / build-frontend (push) Failing after 2s
Build S-UI for Windows / build-windows-amd64 (push) Has been skipped
Build S-UI for Windows / build-windows-arm64 (push) Has been skipped
Signed-off-by: Pavel Kirilin <s3riussan@gmail.com>
26 lines
420 B
Go
26 lines
420 B
Go
package middleware
|
|
|
|
import (
|
|
"net"
|
|
"net/http"
|
|
"strings"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func DomainValidator(domain string) gin.HandlerFunc {
|
|
return func(c *gin.Context) {
|
|
host := c.Request.Host
|
|
if colonIndex := strings.LastIndex(host, ":"); colonIndex != -1 {
|
|
host, _, _ = net.SplitHostPort(c.Request.Host)
|
|
}
|
|
|
|
if host != domain {
|
|
c.AbortWithStatus(http.StatusForbidden)
|
|
return
|
|
}
|
|
|
|
c.Next()
|
|
}
|
|
}
|