Merge pull request #863 from GLYASAI/issue-858

New Feature: make proxy_buffer_size and proxy_buffer_numbers configurable
This commit is contained in:
黄润豪 2020-10-23 13:18:23 +08:00 committed by GitHub
commit 6f1ca23263
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 5 deletions

View File

@ -643,6 +643,16 @@ func (g *GatewayAction) RuleConfig(req *apimodel.RuleConfigReq) error {
Key: "proxy-body-size",
Value: strconv.Itoa(req.Body.ProxyBodySize),
})
configs = append(configs, &model.GwRuleConfig{
RuleID: req.RuleID,
Key: "proxy-buffer-size",
Value: strconv.Itoa(req.Body.ProxyBufferSize) + "k",
})
configs = append(configs, &model.GwRuleConfig{
RuleID: req.RuleID,
Key: "proxy-buffer-numbers",
Value: strconv.Itoa(req.Body.ProxyBufferNumbers),
})
setheaders := make(map[string]string)
for _, item := range req.Body.SetHeaders {
if strings.TrimSpace(item.Key) == "" {
@ -661,10 +671,12 @@ func (g *GatewayAction) RuleConfig(req *apimodel.RuleConfigReq) error {
Value: v,
})
}
rule, err := g.dbmanager.HTTPRuleDao().GetHTTPRuleByID(req.RuleID)
if err != nil {
return err
}
tx := db.GetManager().Begin()
defer func() {
if r := recover(); r != nil {
@ -686,6 +698,7 @@ func (g *GatewayAction) RuleConfig(req *apimodel.RuleConfigReq) error {
tx.Rollback()
return err
}
if err := g.SendTask(map[string]interface{}{
"service_id": req.ServiceID,
"action": "update-rule-config",

View File

@ -129,6 +129,8 @@ type Body struct {
ProxyBodySize int `json:"proxy_body_size,omitempty" validate:"proxy_body_size|required"`
SetHeaders []*SetHeader `json:"set_headers,omitempty" `
Rewrites []*Rewrite `json:"rewrite,omitempty"`
ProxyBufferSize int `json:"proxy_buffer_size,omitempty"`
ProxyBufferNumbers int `json:"proxy_buffer_numbers,omitempty"`
}
//SetHeader set header

View File

@ -4,11 +4,7 @@ set -o errexit
# define package name
WORK_DIR=/go/src/github.com/goodrain/rainbond
BASE_NAME=rainbond
IMAGE_BASE_NAME=rainbond
if [ $BUILD_IMAGE_BASE_NAME ];
then
IMAGE_BASE_NAME=${BUILD_IMAGE_BASE_NAME}
fi
IMAGE_BASE_NAME=${BUILD_IMAGE_BASE_NAME:-'rainbond'}
GO_VERSION=1.13
GATEWAY_GO_VERSION=1.13-alpine