MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / BindDomain

Function BindDomain

core/middleware/bind_domain.go:12–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10)
11
12func BindDomain() gin.HandlerFunc {
13 return func(c *gin.Context) {
14 localRequest := c.GetBool("LOCAL_REQUEST")
15 if localRequest {
16 c.Next()
17 return
18 }
19 settingRepo := repo.NewISettingRepo()
20 bindDomain, err := settingRepo.GetValueByKey("BindDomain")
21 if err != nil {
22 helper.InternalServer(c, err)
23 return
24 }
25 if len(bindDomain) == 0 {
26 c.Next()
27 return
28 }
29 domains := c.Request.Host
30 parts := strings.Split(c.Request.Host, ":")
31 if len(parts) > 0 {
32 domains = parts[0]
33 }
34
35 if domains != bindDomain {
36 code := security.LoadErrCode()
37 helper.ErrWithHtml(c, code, "err_domain")
38 return
39 }
40 c.Next()
41 }
42}

Callers

nothing calls this directly

Calls 2

GetValueByKeyMethod · 0.95
NextMethod · 0.80

Tested by

no test coverage detected