mirror of
https://gitee.com/johng/gf.git
synced 2024-12-03 20:58:47 +08:00
54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
// Copyright 2018 gf Author(https://github.com/gogf/gf). All Rights Reserved.
|
||
//
|
||
// This Source Code Form is subject to the terms of the MIT License.
|
||
// If a copy of the MIT was not distributed with this file,
|
||
// You can obtain one at https://github.com/gogf/gf.
|
||
|
||
package ghttp
|
||
|
||
import "github.com/gogf/gf/os/glog"
|
||
|
||
func (s *Server) SetDenyIps(ips []string) {
|
||
if s.Status() == SERVER_STATUS_RUNNING {
|
||
glog.Error(gCHANGE_CONFIG_WHILE_RUNNING_ERROR)
|
||
return
|
||
}
|
||
s.config.DenyIps = ips
|
||
}
|
||
|
||
func (s *Server) SetAllowIps(ips []string) {
|
||
if s.Status() == SERVER_STATUS_RUNNING {
|
||
glog.Error(gCHANGE_CONFIG_WHILE_RUNNING_ERROR)
|
||
return
|
||
}
|
||
s.config.AllowIps = ips
|
||
}
|
||
|
||
func (s *Server) SetDenyRoutes(routes []string) {
|
||
if s.Status() == SERVER_STATUS_RUNNING {
|
||
glog.Error(gCHANGE_CONFIG_WHILE_RUNNING_ERROR)
|
||
return
|
||
}
|
||
s.config.DenyRoutes = routes
|
||
}
|
||
|
||
// 设置URI重写规则
|
||
func (s *Server) SetRewrite(uri string, rewrite string) {
|
||
if s.Status() == SERVER_STATUS_RUNNING {
|
||
glog.Error(gCHANGE_CONFIG_WHILE_RUNNING_ERROR)
|
||
return
|
||
}
|
||
s.config.Rewrites[uri] = rewrite
|
||
}
|
||
|
||
// 设置URI重写规则(批量)
|
||
func (s *Server) SetRewriteMap(rewrites map[string]string) {
|
||
if s.Status() == SERVER_STATUS_RUNNING {
|
||
glog.Error(gCHANGE_CONFIG_WHILE_RUNNING_ERROR)
|
||
return
|
||
}
|
||
for k, v := range rewrites {
|
||
s.config.Rewrites[k] = v
|
||
}
|
||
}
|