mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 07:50:25 +08:00 
			
		
		
		
	优化访问日志策略测试时的失败提示
This commit is contained in:
		@@ -1,7 +1,6 @@
 | 
			
		||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
 | 
			
		||||
 | 
			
		||||
//go:build !plus
 | 
			
		||||
// +build !plus
 | 
			
		||||
 | 
			
		||||
package accesslogs
 | 
			
		||||
 | 
			
		||||
@@ -10,6 +9,6 @@ import (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// 写入日志
 | 
			
		||||
func (this *StorageManager) Write(policyId int64, accessLogs []*pb.HTTPAccessLog) error {
 | 
			
		||||
	return nil
 | 
			
		||||
func (this *StorageManager) Write(policyId int64, accessLogs []*pb.HTTPAccessLog) (success bool, failMessage string, err error) {
 | 
			
		||||
	return false, "only works in plus version", nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -43,7 +43,7 @@ func (this *HTTPAccessLogService) CreateHTTPAccessLogs(ctx context.Context, req
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	if policyId > 0 {
 | 
			
		||||
		err = accesslogs.SharedStorageManager.Write(policyId, req.HttpAccessLogs)
 | 
			
		||||
		_, _, err = accesslogs.SharedStorageManager.Write(policyId, req.HttpAccessLogs)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,7 @@ package services
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAPI/internal/accesslogs"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAPI/internal/db/models"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
			
		||||
@@ -153,9 +154,12 @@ func (this *HTTPAccessLogPolicyService) WriteHTTPAccessLogPolicy(ctx context.Con
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	err = accesslogs.SharedStorageManager.Write(req.HttpAccessLogPolicyId, []*pb.HTTPAccessLog{req.HttpAccessLog})
 | 
			
		||||
	success, failMessage, err := accesslogs.SharedStorageManager.Write(req.HttpAccessLogPolicyId, []*pb.HTTPAccessLog{req.HttpAccessLog})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	if !success {
 | 
			
		||||
		return nil, errors.New("test failed: " + failMessage)
 | 
			
		||||
	}
 | 
			
		||||
	return this.Success()
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user