Files
EdgeNode/internal/nodes/http_request_traffic_limit.go

27 lines
768 B
Go
Raw Normal View History

// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package nodes
import (
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
)
2021-11-09 17:36:49 +08:00
// 流量限制
func (this *HTTPRequest) doTrafficLimit() {
2023-09-06 16:34:11 +08:00
this.tags = append(this.tags, "trafficLimit")
var statusCode = 509
2023-09-06 16:34:11 +08:00
this.writer.statusCode = statusCode
this.ProcessResponseHeaders(this.writer.Header(), statusCode)
2023-09-06 16:34:11 +08:00
this.writer.Header().Set("Content-Type", "text/html; charset=utf-8")
this.writer.WriteHeader(statusCode)
2023-09-06 16:34:11 +08:00
var config = this.ReqServer.TrafficLimit
if config != nil && len(config.NoticePageBody) != 0 {
_, _ = this.writer.WriteString(this.Format(config.NoticePageBody))
} else {
_, _ = this.writer.WriteString(this.Format(serverconfigs.DefaultTrafficLimitNoticePageBody))
}
}