Files
EdgeNode/internal/nodes/http_request_traffic_limit.go

25 lines
619 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() {
2022-01-01 20:15:39 +08:00
var config = this.ReqServer.TrafficLimit
this.tags = append(this.tags, "bandwidth")
var statusCode = 509
this.processResponseHeaders(statusCode)
this.writer.WriteHeader(statusCode)
if len(config.NoticePageBody) != 0 {
_, _ = this.writer.WriteString(this.Format(config.NoticePageBody))
} else {
_, _ = this.writer.WriteString(this.Format(serverconfigs.DefaultTrafficLimitNoticePageBody))
}
}