实现访问日志配置

This commit is contained in:
GoEdgeLab
2020-09-20 11:56:22 +08:00
parent bdaa090b5d
commit e7d37ea6dc
15 changed files with 1203 additions and 144 deletions

View File

@@ -0,0 +1,195 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.12.3
// source: model_http_access_log_policy.proto
package pb
import (
proto "github.com/golang/protobuf/proto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type HTTPAccessLogPolicy struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
IsOn bool `protobuf:"varint,3,opt,name=isOn,proto3" json:"isOn,omitempty"`
Type string `protobuf:"bytes,4,opt,name=type,proto3" json:"type,omitempty"`
OptionsJSON []byte `protobuf:"bytes,5,opt,name=optionsJSON,proto3" json:"optionsJSON,omitempty"`
CondsJSON []byte `protobuf:"bytes,6,opt,name=condsJSON,proto3" json:"condsJSON,omitempty"`
}
func (x *HTTPAccessLogPolicy) Reset() {
*x = HTTPAccessLogPolicy{}
if protoimpl.UnsafeEnabled {
mi := &file_model_http_access_log_policy_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *HTTPAccessLogPolicy) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*HTTPAccessLogPolicy) ProtoMessage() {}
func (x *HTTPAccessLogPolicy) ProtoReflect() protoreflect.Message {
mi := &file_model_http_access_log_policy_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use HTTPAccessLogPolicy.ProtoReflect.Descriptor instead.
func (*HTTPAccessLogPolicy) Descriptor() ([]byte, []int) {
return file_model_http_access_log_policy_proto_rawDescGZIP(), []int{0}
}
func (x *HTTPAccessLogPolicy) GetId() int64 {
if x != nil {
return x.Id
}
return 0
}
func (x *HTTPAccessLogPolicy) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *HTTPAccessLogPolicy) GetIsOn() bool {
if x != nil {
return x.IsOn
}
return false
}
func (x *HTTPAccessLogPolicy) GetType() string {
if x != nil {
return x.Type
}
return ""
}
func (x *HTTPAccessLogPolicy) GetOptionsJSON() []byte {
if x != nil {
return x.OptionsJSON
}
return nil
}
func (x *HTTPAccessLogPolicy) GetCondsJSON() []byte {
if x != nil {
return x.CondsJSON
}
return nil
}
var File_model_http_access_log_policy_proto protoreflect.FileDescriptor
var file_model_http_access_log_policy_proto_rawDesc = []byte{
0x0a, 0x22, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x68, 0x74, 0x74, 0x70, 0x5f, 0x61, 0x63, 0x63,
0x65, 0x73, 0x73, 0x5f, 0x6c, 0x6f, 0x67, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0xa1, 0x01, 0x0a, 0x13, 0x48, 0x54, 0x54,
0x50, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4c, 0x6f, 0x67, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79,
0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64,
0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x18, 0x03, 0x20, 0x01,
0x28, 0x08, 0x52, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65,
0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x20, 0x0a, 0x0b,
0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x05, 0x20, 0x01, 0x28,
0x0c, 0x52, 0x0b, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x1c,
0x0a, 0x09, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x06, 0x20, 0x01, 0x28,
0x0c, 0x52, 0x09, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x42, 0x06, 0x5a, 0x04,
0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_model_http_access_log_policy_proto_rawDescOnce sync.Once
file_model_http_access_log_policy_proto_rawDescData = file_model_http_access_log_policy_proto_rawDesc
)
func file_model_http_access_log_policy_proto_rawDescGZIP() []byte {
file_model_http_access_log_policy_proto_rawDescOnce.Do(func() {
file_model_http_access_log_policy_proto_rawDescData = protoimpl.X.CompressGZIP(file_model_http_access_log_policy_proto_rawDescData)
})
return file_model_http_access_log_policy_proto_rawDescData
}
var file_model_http_access_log_policy_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_model_http_access_log_policy_proto_goTypes = []interface{}{
(*HTTPAccessLogPolicy)(nil), // 0: pb.HTTPAccessLogPolicy
}
var file_model_http_access_log_policy_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_model_http_access_log_policy_proto_init() }
func file_model_http_access_log_policy_proto_init() {
if File_model_http_access_log_policy_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_model_http_access_log_policy_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*HTTPAccessLogPolicy); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_model_http_access_log_policy_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_model_http_access_log_policy_proto_goTypes,
DependencyIndexes: file_model_http_access_log_policy_proto_depIdxs,
MessageInfos: file_model_http_access_log_policy_proto_msgTypes,
}.Build()
File_model_http_access_log_policy_proto = out.File
file_model_http_access_log_policy_proto_rawDesc = nil
file_model_http_access_log_policy_proto_goTypes = nil
file_model_http_access_log_policy_proto_depIdxs = nil
}

View File

@@ -0,0 +1,311 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.12.3
// source: service_http_access_log_policy.proto
package pb
import (
context "context"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
// 获取所有可用策略
type FindAllEnabledHTTPAccessLogPoliciesRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *FindAllEnabledHTTPAccessLogPoliciesRequest) Reset() {
*x = FindAllEnabledHTTPAccessLogPoliciesRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_service_http_access_log_policy_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *FindAllEnabledHTTPAccessLogPoliciesRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*FindAllEnabledHTTPAccessLogPoliciesRequest) ProtoMessage() {}
func (x *FindAllEnabledHTTPAccessLogPoliciesRequest) ProtoReflect() protoreflect.Message {
mi := &file_service_http_access_log_policy_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use FindAllEnabledHTTPAccessLogPoliciesRequest.ProtoReflect.Descriptor instead.
func (*FindAllEnabledHTTPAccessLogPoliciesRequest) Descriptor() ([]byte, []int) {
return file_service_http_access_log_policy_proto_rawDescGZIP(), []int{0}
}
type FindAllEnabledHTTPAccessLogPoliciesResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
AccessLogPolicies []*HTTPAccessLogPolicy `protobuf:"bytes,1,rep,name=accessLogPolicies,proto3" json:"accessLogPolicies,omitempty"`
}
func (x *FindAllEnabledHTTPAccessLogPoliciesResponse) Reset() {
*x = FindAllEnabledHTTPAccessLogPoliciesResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_service_http_access_log_policy_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *FindAllEnabledHTTPAccessLogPoliciesResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*FindAllEnabledHTTPAccessLogPoliciesResponse) ProtoMessage() {}
func (x *FindAllEnabledHTTPAccessLogPoliciesResponse) ProtoReflect() protoreflect.Message {
mi := &file_service_http_access_log_policy_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use FindAllEnabledHTTPAccessLogPoliciesResponse.ProtoReflect.Descriptor instead.
func (*FindAllEnabledHTTPAccessLogPoliciesResponse) Descriptor() ([]byte, []int) {
return file_service_http_access_log_policy_proto_rawDescGZIP(), []int{1}
}
func (x *FindAllEnabledHTTPAccessLogPoliciesResponse) GetAccessLogPolicies() []*HTTPAccessLogPolicy {
if x != nil {
return x.AccessLogPolicies
}
return nil
}
var File_service_http_access_log_policy_proto protoreflect.FileDescriptor
var file_service_http_access_log_policy_proto_rawDesc = []byte{
0x0a, 0x24, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x68, 0x74, 0x74, 0x70, 0x5f, 0x61,
0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x6c, 0x6f, 0x67, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x22, 0x6d, 0x6f, 0x64, 0x65,
0x6c, 0x5f, 0x68, 0x74, 0x74, 0x70, 0x5f, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x6c, 0x6f,
0x67, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2c,
0x0a, 0x2a, 0x46, 0x69, 0x6e, 0x64, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64,
0x48, 0x54, 0x54, 0x50, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4c, 0x6f, 0x67, 0x50, 0x6f, 0x6c,
0x69, 0x63, 0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x74, 0x0a, 0x2b,
0x46, 0x69, 0x6e, 0x64, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54,
0x54, 0x50, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4c, 0x6f, 0x67, 0x50, 0x6f, 0x6c, 0x69, 0x63,
0x69, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x45, 0x0a, 0x11, 0x61,
0x63, 0x63, 0x65, 0x73, 0x73, 0x4c, 0x6f, 0x67, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73,
0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x70, 0x62, 0x2e, 0x48, 0x54, 0x54, 0x50,
0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4c, 0x6f, 0x67, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52,
0x11, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4c, 0x6f, 0x67, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69,
0x65, 0x73, 0x32, 0xa5, 0x01, 0x0a, 0x1a, 0x48, 0x54, 0x54, 0x50, 0x41, 0x63, 0x63, 0x65, 0x73,
0x73, 0x4c, 0x6f, 0x67, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
0x65, 0x12, 0x86, 0x01, 0x0a, 0x23, 0x66, 0x69, 0x6e, 0x64, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61,
0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4c, 0x6f,
0x67, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x12, 0x2e, 0x2e, 0x70, 0x62, 0x2e, 0x46,
0x69, 0x6e, 0x64, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54,
0x50, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4c, 0x6f, 0x67, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69,
0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, 0x2e, 0x70, 0x62, 0x2e, 0x46,
0x69, 0x6e, 0x64, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54,
0x50, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4c, 0x6f, 0x67, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69,
0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f,
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_service_http_access_log_policy_proto_rawDescOnce sync.Once
file_service_http_access_log_policy_proto_rawDescData = file_service_http_access_log_policy_proto_rawDesc
)
func file_service_http_access_log_policy_proto_rawDescGZIP() []byte {
file_service_http_access_log_policy_proto_rawDescOnce.Do(func() {
file_service_http_access_log_policy_proto_rawDescData = protoimpl.X.CompressGZIP(file_service_http_access_log_policy_proto_rawDescData)
})
return file_service_http_access_log_policy_proto_rawDescData
}
var file_service_http_access_log_policy_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_service_http_access_log_policy_proto_goTypes = []interface{}{
(*FindAllEnabledHTTPAccessLogPoliciesRequest)(nil), // 0: pb.FindAllEnabledHTTPAccessLogPoliciesRequest
(*FindAllEnabledHTTPAccessLogPoliciesResponse)(nil), // 1: pb.FindAllEnabledHTTPAccessLogPoliciesResponse
(*HTTPAccessLogPolicy)(nil), // 2: pb.HTTPAccessLogPolicy
}
var file_service_http_access_log_policy_proto_depIdxs = []int32{
2, // 0: pb.FindAllEnabledHTTPAccessLogPoliciesResponse.accessLogPolicies:type_name -> pb.HTTPAccessLogPolicy
0, // 1: pb.HTTPAccessLogPolicyService.findAllEnabledHTTPAccessLogPolicies:input_type -> pb.FindAllEnabledHTTPAccessLogPoliciesRequest
1, // 2: pb.HTTPAccessLogPolicyService.findAllEnabledHTTPAccessLogPolicies:output_type -> pb.FindAllEnabledHTTPAccessLogPoliciesResponse
2, // [2:3] is the sub-list for method output_type
1, // [1:2] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_service_http_access_log_policy_proto_init() }
func file_service_http_access_log_policy_proto_init() {
if File_service_http_access_log_policy_proto != nil {
return
}
file_model_http_access_log_policy_proto_init()
if !protoimpl.UnsafeEnabled {
file_service_http_access_log_policy_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*FindAllEnabledHTTPAccessLogPoliciesRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_http_access_log_policy_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*FindAllEnabledHTTPAccessLogPoliciesResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_service_http_access_log_policy_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_service_http_access_log_policy_proto_goTypes,
DependencyIndexes: file_service_http_access_log_policy_proto_depIdxs,
MessageInfos: file_service_http_access_log_policy_proto_msgTypes,
}.Build()
File_service_http_access_log_policy_proto = out.File
file_service_http_access_log_policy_proto_rawDesc = nil
file_service_http_access_log_policy_proto_goTypes = nil
file_service_http_access_log_policy_proto_depIdxs = nil
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion6
// HTTPAccessLogPolicyServiceClient is the client API for HTTPAccessLogPolicyService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type HTTPAccessLogPolicyServiceClient interface {
// 获取所有可用策略
FindAllEnabledHTTPAccessLogPolicies(ctx context.Context, in *FindAllEnabledHTTPAccessLogPoliciesRequest, opts ...grpc.CallOption) (*FindAllEnabledHTTPAccessLogPoliciesResponse, error)
}
type hTTPAccessLogPolicyServiceClient struct {
cc grpc.ClientConnInterface
}
func NewHTTPAccessLogPolicyServiceClient(cc grpc.ClientConnInterface) HTTPAccessLogPolicyServiceClient {
return &hTTPAccessLogPolicyServiceClient{cc}
}
func (c *hTTPAccessLogPolicyServiceClient) FindAllEnabledHTTPAccessLogPolicies(ctx context.Context, in *FindAllEnabledHTTPAccessLogPoliciesRequest, opts ...grpc.CallOption) (*FindAllEnabledHTTPAccessLogPoliciesResponse, error) {
out := new(FindAllEnabledHTTPAccessLogPoliciesResponse)
err := c.cc.Invoke(ctx, "/pb.HTTPAccessLogPolicyService/findAllEnabledHTTPAccessLogPolicies", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// HTTPAccessLogPolicyServiceServer is the server API for HTTPAccessLogPolicyService service.
type HTTPAccessLogPolicyServiceServer interface {
// 获取所有可用策略
FindAllEnabledHTTPAccessLogPolicies(context.Context, *FindAllEnabledHTTPAccessLogPoliciesRequest) (*FindAllEnabledHTTPAccessLogPoliciesResponse, error)
}
// UnimplementedHTTPAccessLogPolicyServiceServer can be embedded to have forward compatible implementations.
type UnimplementedHTTPAccessLogPolicyServiceServer struct {
}
func (*UnimplementedHTTPAccessLogPolicyServiceServer) FindAllEnabledHTTPAccessLogPolicies(context.Context, *FindAllEnabledHTTPAccessLogPoliciesRequest) (*FindAllEnabledHTTPAccessLogPoliciesResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method FindAllEnabledHTTPAccessLogPolicies not implemented")
}
func RegisterHTTPAccessLogPolicyServiceServer(s *grpc.Server, srv HTTPAccessLogPolicyServiceServer) {
s.RegisterService(&_HTTPAccessLogPolicyService_serviceDesc, srv)
}
func _HTTPAccessLogPolicyService_FindAllEnabledHTTPAccessLogPolicies_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(FindAllEnabledHTTPAccessLogPoliciesRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HTTPAccessLogPolicyServiceServer).FindAllEnabledHTTPAccessLogPolicies(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/pb.HTTPAccessLogPolicyService/FindAllEnabledHTTPAccessLogPolicies",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HTTPAccessLogPolicyServiceServer).FindAllEnabledHTTPAccessLogPolicies(ctx, req.(*FindAllEnabledHTTPAccessLogPoliciesRequest))
}
return interceptor(ctx, in, info, handler)
}
var _HTTPAccessLogPolicyService_serviceDesc = grpc.ServiceDesc{
ServiceName: "pb.HTTPAccessLogPolicyService",
HandlerType: (*HTTPAccessLogPolicyServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "findAllEnabledHTTPAccessLogPolicies",
Handler: _HTTPAccessLogPolicyService_FindAllEnabledHTTPAccessLogPolicies_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "service_http_access_log_policy.proto",
}

View File

@@ -611,6 +611,62 @@ func (x *UpdateHTTPWebPagesRequest) GetPagesJSON() []byte {
return nil
}
// 更改访问日志配置
type UpdateHTTPAccessLogRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
WebId int64 `protobuf:"varint,1,opt,name=webId,proto3" json:"webId,omitempty"`
AccessLogJSON []byte `protobuf:"bytes,2,opt,name=accessLogJSON,proto3" json:"accessLogJSON,omitempty"`
}
func (x *UpdateHTTPAccessLogRequest) Reset() {
*x = UpdateHTTPAccessLogRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_service_http_web_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UpdateHTTPAccessLogRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UpdateHTTPAccessLogRequest) ProtoMessage() {}
func (x *UpdateHTTPAccessLogRequest) ProtoReflect() protoreflect.Message {
mi := &file_service_http_web_proto_msgTypes[11]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use UpdateHTTPAccessLogRequest.ProtoReflect.Descriptor instead.
func (*UpdateHTTPAccessLogRequest) Descriptor() ([]byte, []int) {
return file_service_http_web_proto_rawDescGZIP(), []int{11}
}
func (x *UpdateHTTPAccessLogRequest) GetWebId() int64 {
if x != nil {
return x.WebId
}
return 0
}
func (x *UpdateHTTPAccessLogRequest) GetAccessLogJSON() []byte {
if x != nil {
return x.AccessLogJSON
}
return nil
}
var File_service_http_web_proto protoreflect.FileDescriptor
var file_service_http_web_proto_rawDesc = []byte{
@@ -668,55 +724,66 @@ var file_service_http_web_proto_rawDesc = []byte{
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x77, 0x65, 0x62, 0x49, 0x64, 0x18,
0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x77, 0x65, 0x62, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09,
0x70, 0x61, 0x67, 0x65, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52,
0x09, 0x70, 0x61, 0x67, 0x65, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x32, 0xf0, 0x05, 0x0a, 0x0e, 0x48,
0x54, 0x54, 0x50, 0x57, 0x65, 0x62, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x44, 0x0a,
0x0d, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65, 0x62, 0x12, 0x18,
0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65,
0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72,
0x65, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65, 0x62, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x53, 0x0a, 0x12, 0x66, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c,
0x65, 0x64, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65, 0x62, 0x12, 0x1d, 0x2e, 0x70, 0x62, 0x2e, 0x46,
0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65,
0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69,
0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65, 0x62,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3f, 0x0a, 0x0d, 0x75, 0x70, 0x64, 0x61,
0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65, 0x62, 0x12, 0x18, 0x2e, 0x70, 0x62, 0x2e, 0x55,
0x09, 0x70, 0x61, 0x67, 0x65, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x22, 0x58, 0x0a, 0x1a, 0x55, 0x70,
0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4c, 0x6f,
0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x77, 0x65, 0x62, 0x49,
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x77, 0x65, 0x62, 0x49, 0x64, 0x12, 0x24,
0x0a, 0x0d, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4c, 0x6f, 0x67, 0x4a, 0x53, 0x4f, 0x4e, 0x18,
0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4c, 0x6f, 0x67,
0x4a, 0x53, 0x4f, 0x4e, 0x32, 0xbd, 0x06, 0x0a, 0x0e, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65, 0x62,
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x44, 0x0a, 0x0d, 0x63, 0x72, 0x65, 0x61, 0x74,
0x65, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65, 0x62, 0x12, 0x18, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72,
0x65, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x19, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x48, 0x54,
0x54, 0x50, 0x57, 0x65, 0x62, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x53, 0x0a,
0x12, 0x66, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50,
0x57, 0x65, 0x62, 0x12, 0x1d, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61,
0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62,
0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65, 0x62, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x3f, 0x0a, 0x0d, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50,
0x57, 0x65, 0x62, 0x12, 0x18, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48,
0x54, 0x54, 0x50, 0x57, 0x65, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e,
0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x63, 0x63,
0x65, 0x73, 0x73, 0x12, 0x47, 0x0a, 0x11, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54,
0x50, 0x57, 0x65, 0x62, 0x47, 0x7a, 0x69, 0x70, 0x12, 0x1c, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70,
0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65, 0x62, 0x47, 0x7a, 0x69, 0x70, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x55,
0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x4d, 0x0a, 0x14,
0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65, 0x62, 0x43, 0x68, 0x61,
0x72, 0x73, 0x65, 0x74, 0x12, 0x1f, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65,
0x48, 0x54, 0x54, 0x50, 0x57, 0x65, 0x62, 0x43, 0x68, 0x61, 0x72, 0x73, 0x65, 0x74, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x55, 0x70,
0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x65, 0x0a, 0x20, 0x75,
0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65, 0x62, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x55, 0x70, 0x64, 0x61,
0x74, 0x65, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x47, 0x0a, 0x11, 0x75, 0x70, 0x64,
0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65, 0x62, 0x47, 0x7a, 0x69, 0x70, 0x12, 0x1c,
0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65,
0x62, 0x47, 0x7a, 0x69, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70,
0x62, 0x2e, 0x52, 0x50, 0x43, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x63, 0x63, 0x65,
0x73, 0x73, 0x12, 0x4d, 0x0a, 0x14, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50,
0x57, 0x65, 0x62, 0x43, 0x68, 0x61, 0x72, 0x73, 0x65, 0x74, 0x12, 0x1f, 0x2e, 0x70, 0x62, 0x2e,
0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65, 0x62, 0x43, 0x68, 0x61,
0x72, 0x73, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x62,
0x2e, 0x52, 0x50, 0x43, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73,
0x73, 0x12, 0x65, 0x0a, 0x20, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x57,
0x65, 0x73, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12,
0x2b, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x57,
0x65, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x50,
0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x2b, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74,
0x65, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48,
0x65, 0x61, 0x64, 0x65, 0x72, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x55, 0x70, 0x64, 0x61, 0x74,
0x65, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x67, 0x0a, 0x21, 0x75, 0x70, 0x64, 0x61,
0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65, 0x62, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x2c, 0x2e,
0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65, 0x62,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x50, 0x6f,
0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x62,
0x2e, 0x52, 0x50, 0x43, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73,
0x73, 0x12, 0x4f, 0x0a, 0x15, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x57,
0x65, 0x62, 0x53, 0x68, 0x75, 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x12, 0x20, 0x2e, 0x70, 0x62, 0x2e,
0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65, 0x62, 0x53, 0x68, 0x75,
0x74, 0x64, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70,
0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70,
0x62, 0x2e, 0x52, 0x50, 0x43, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x63, 0x63, 0x65,
0x73, 0x73, 0x12, 0x49, 0x0a, 0x12, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50,
0x57, 0x65, 0x62, 0x50, 0x61, 0x67, 0x65, 0x73, 0x12, 0x1d, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70,
0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65, 0x62, 0x50, 0x61, 0x67, 0x65, 0x73,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43,
0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x42, 0x06, 0x5a,
0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x73, 0x73, 0x12, 0x67, 0x0a, 0x21, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50,
0x57, 0x65, 0x62, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x65, 0x61, 0x64, 0x65,
0x72, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x2c, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64,
0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65, 0x62, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x55, 0x70,
0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x4f, 0x0a, 0x15, 0x75,
0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65, 0x62, 0x53, 0x68, 0x75, 0x74,
0x64, 0x6f, 0x77, 0x6e, 0x12, 0x20, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65,
0x48, 0x54, 0x54, 0x50, 0x57, 0x65, 0x62, 0x53, 0x68, 0x75, 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x55,
0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x49, 0x0a, 0x12,
0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x57, 0x65, 0x62, 0x50, 0x61, 0x67,
0x65, 0x73, 0x12, 0x1d, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54,
0x54, 0x50, 0x57, 0x65, 0x62, 0x50, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x14, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65,
0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x4b, 0x0a, 0x13, 0x75, 0x70, 0x64, 0x61, 0x74,
0x65, 0x48, 0x54, 0x54, 0x50, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4c, 0x6f, 0x67, 0x12, 0x1e,
0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x41, 0x63,
0x63, 0x65, 0x73, 0x73, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14,
0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x63,
0x63, 0x65, 0x73, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -731,7 +798,7 @@ func file_service_http_web_proto_rawDescGZIP() []byte {
return file_service_http_web_proto_rawDescData
}
var file_service_http_web_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
var file_service_http_web_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
var file_service_http_web_proto_goTypes = []interface{}{
(*CreateHTTPWebRequest)(nil), // 0: pb.CreateHTTPWebRequest
(*CreateHTTPWebResponse)(nil), // 1: pb.CreateHTTPWebResponse
@@ -744,11 +811,12 @@ var file_service_http_web_proto_goTypes = []interface{}{
(*UpdateHTTPWebResponseHeaderPolicyRequest)(nil), // 8: pb.UpdateHTTPWebResponseHeaderPolicyRequest
(*UpdateHTTPWebShutdownRequest)(nil), // 9: pb.UpdateHTTPWebShutdownRequest
(*UpdateHTTPWebPagesRequest)(nil), // 10: pb.UpdateHTTPWebPagesRequest
(*HTTPWeb)(nil), // 11: pb.HTTPWeb
(*RPCUpdateSuccess)(nil), // 12: pb.RPCUpdateSuccess
(*UpdateHTTPAccessLogRequest)(nil), // 11: pb.UpdateHTTPAccessLogRequest
(*HTTPWeb)(nil), // 12: pb.HTTPWeb
(*RPCUpdateSuccess)(nil), // 13: pb.RPCUpdateSuccess
}
var file_service_http_web_proto_depIdxs = []int32{
11, // 0: pb.FindEnabledHTTPWebResponse.web:type_name -> pb.HTTPWeb
12, // 0: pb.FindEnabledHTTPWebResponse.web:type_name -> pb.HTTPWeb
0, // 1: pb.HTTPWebService.createHTTPWeb:input_type -> pb.CreateHTTPWebRequest
2, // 2: pb.HTTPWebService.findEnabledHTTPWeb:input_type -> pb.FindEnabledHTTPWebRequest
4, // 3: pb.HTTPWebService.updateHTTPWeb:input_type -> pb.UpdateHTTPWebRequest
@@ -758,17 +826,19 @@ var file_service_http_web_proto_depIdxs = []int32{
8, // 7: pb.HTTPWebService.updateHTTPWebResponseHeaderPolicy:input_type -> pb.UpdateHTTPWebResponseHeaderPolicyRequest
9, // 8: pb.HTTPWebService.updateHTTPWebShutdown:input_type -> pb.UpdateHTTPWebShutdownRequest
10, // 9: pb.HTTPWebService.updateHTTPWebPages:input_type -> pb.UpdateHTTPWebPagesRequest
1, // 10: pb.HTTPWebService.createHTTPWeb:output_type -> pb.CreateHTTPWebResponse
3, // 11: pb.HTTPWebService.findEnabledHTTPWeb:output_type -> pb.FindEnabledHTTPWebResponse
12, // 12: pb.HTTPWebService.updateHTTPWeb:output_type -> pb.RPCUpdateSuccess
12, // 13: pb.HTTPWebService.updateHTTPWebGzip:output_type -> pb.RPCUpdateSuccess
12, // 14: pb.HTTPWebService.updateHTTPWebCharset:output_type -> pb.RPCUpdateSuccess
12, // 15: pb.HTTPWebService.updateHTTPWebRequestHeaderPolicy:output_type -> pb.RPCUpdateSuccess
12, // 16: pb.HTTPWebService.updateHTTPWebResponseHeaderPolicy:output_type -> pb.RPCUpdateSuccess
12, // 17: pb.HTTPWebService.updateHTTPWebShutdown:output_type -> pb.RPCUpdateSuccess
12, // 18: pb.HTTPWebService.updateHTTPWebPages:output_type -> pb.RPCUpdateSuccess
10, // [10:19] is the sub-list for method output_type
1, // [1:10] is the sub-list for method input_type
11, // 10: pb.HTTPWebService.updateHTTPAccessLog:input_type -> pb.UpdateHTTPAccessLogRequest
1, // 11: pb.HTTPWebService.createHTTPWeb:output_type -> pb.CreateHTTPWebResponse
3, // 12: pb.HTTPWebService.findEnabledHTTPWeb:output_type -> pb.FindEnabledHTTPWebResponse
13, // 13: pb.HTTPWebService.updateHTTPWeb:output_type -> pb.RPCUpdateSuccess
13, // 14: pb.HTTPWebService.updateHTTPWebGzip:output_type -> pb.RPCUpdateSuccess
13, // 15: pb.HTTPWebService.updateHTTPWebCharset:output_type -> pb.RPCUpdateSuccess
13, // 16: pb.HTTPWebService.updateHTTPWebRequestHeaderPolicy:output_type -> pb.RPCUpdateSuccess
13, // 17: pb.HTTPWebService.updateHTTPWebResponseHeaderPolicy:output_type -> pb.RPCUpdateSuccess
13, // 18: pb.HTTPWebService.updateHTTPWebShutdown:output_type -> pb.RPCUpdateSuccess
13, // 19: pb.HTTPWebService.updateHTTPWebPages:output_type -> pb.RPCUpdateSuccess
13, // 20: pb.HTTPWebService.updateHTTPAccessLog:output_type -> pb.RPCUpdateSuccess
11, // [11:21] is the sub-list for method output_type
1, // [1:11] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
@@ -914,6 +984,18 @@ func file_service_http_web_proto_init() {
return nil
}
}
file_service_http_web_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UpdateHTTPAccessLogRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
@@ -921,7 +1003,7 @@ func file_service_http_web_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_service_http_web_proto_rawDesc,
NumEnums: 0,
NumMessages: 11,
NumMessages: 12,
NumExtensions: 0,
NumServices: 1,
},
@@ -965,6 +1047,8 @@ type HTTPWebServiceClient interface {
UpdateHTTPWebShutdown(ctx context.Context, in *UpdateHTTPWebShutdownRequest, opts ...grpc.CallOption) (*RPCUpdateSuccess, error)
// 更改Pages
UpdateHTTPWebPages(ctx context.Context, in *UpdateHTTPWebPagesRequest, opts ...grpc.CallOption) (*RPCUpdateSuccess, error)
// 更改访问日志配置
UpdateHTTPAccessLog(ctx context.Context, in *UpdateHTTPAccessLogRequest, opts ...grpc.CallOption) (*RPCUpdateSuccess, error)
}
type hTTPWebServiceClient struct {
@@ -1056,6 +1140,15 @@ func (c *hTTPWebServiceClient) UpdateHTTPWebPages(ctx context.Context, in *Updat
return out, nil
}
func (c *hTTPWebServiceClient) UpdateHTTPAccessLog(ctx context.Context, in *UpdateHTTPAccessLogRequest, opts ...grpc.CallOption) (*RPCUpdateSuccess, error) {
out := new(RPCUpdateSuccess)
err := c.cc.Invoke(ctx, "/pb.HTTPWebService/updateHTTPAccessLog", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// HTTPWebServiceServer is the server API for HTTPWebService service.
type HTTPWebServiceServer interface {
// 创建Web配置
@@ -1076,6 +1169,8 @@ type HTTPWebServiceServer interface {
UpdateHTTPWebShutdown(context.Context, *UpdateHTTPWebShutdownRequest) (*RPCUpdateSuccess, error)
// 更改Pages
UpdateHTTPWebPages(context.Context, *UpdateHTTPWebPagesRequest) (*RPCUpdateSuccess, error)
// 更改访问日志配置
UpdateHTTPAccessLog(context.Context, *UpdateHTTPAccessLogRequest) (*RPCUpdateSuccess, error)
}
// UnimplementedHTTPWebServiceServer can be embedded to have forward compatible implementations.
@@ -1109,6 +1204,9 @@ func (*UnimplementedHTTPWebServiceServer) UpdateHTTPWebShutdown(context.Context,
func (*UnimplementedHTTPWebServiceServer) UpdateHTTPWebPages(context.Context, *UpdateHTTPWebPagesRequest) (*RPCUpdateSuccess, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateHTTPWebPages not implemented")
}
func (*UnimplementedHTTPWebServiceServer) UpdateHTTPAccessLog(context.Context, *UpdateHTTPAccessLogRequest) (*RPCUpdateSuccess, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateHTTPAccessLog not implemented")
}
func RegisterHTTPWebServiceServer(s *grpc.Server, srv HTTPWebServiceServer) {
s.RegisterService(&_HTTPWebService_serviceDesc, srv)
@@ -1276,6 +1374,24 @@ func _HTTPWebService_UpdateHTTPWebPages_Handler(srv interface{}, ctx context.Con
return interceptor(ctx, in, info, handler)
}
func _HTTPWebService_UpdateHTTPAccessLog_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UpdateHTTPAccessLogRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HTTPWebServiceServer).UpdateHTTPAccessLog(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/pb.HTTPWebService/UpdateHTTPAccessLog",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HTTPWebServiceServer).UpdateHTTPAccessLog(ctx, req.(*UpdateHTTPAccessLogRequest))
}
return interceptor(ctx, in, info, handler)
}
var _HTTPWebService_serviceDesc = grpc.ServiceDesc{
ServiceName: "pb.HTTPWebService",
HandlerType: (*HTTPWebServiceServer)(nil),
@@ -1316,6 +1432,10 @@ var _HTTPWebService_serviceDesc = grpc.ServiceDesc{
MethodName: "updateHTTPWebPages",
Handler: _HTTPWebService_UpdateHTTPWebPages_Handler,
},
{
MethodName: "updateHTTPAccessLog",
Handler: _HTTPWebService_UpdateHTTPAccessLog_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "service_http_web.proto",

View File

@@ -0,0 +1,13 @@
syntax = "proto3";
option go_package = "./pb";
package pb;
message HTTPAccessLogPolicy {
int64 id = 1;
string name = 2;
bool isOn = 3;
string type = 4;
bytes optionsJSON = 5;
bytes condsJSON = 6;
}

View File

@@ -0,0 +1,21 @@
syntax = "proto3";
option go_package = "./pb";
package pb;
import "model_http_access_log_policy.proto";
service HTTPAccessLogPolicyService {
// 获取所有可用策略
rpc findAllEnabledHTTPAccessLogPolicies (FindAllEnabledHTTPAccessLogPoliciesRequest) returns (FindAllEnabledHTTPAccessLogPoliciesResponse);
}
// 获取所有可用策略
message FindAllEnabledHTTPAccessLogPoliciesRequest {
}
message FindAllEnabledHTTPAccessLogPoliciesResponse {
repeated HTTPAccessLogPolicy accessLogPolicies = 1;
}

View File

@@ -33,6 +33,9 @@ service HTTPWebService {
// 更改Pages
rpc updateHTTPWebPages (UpdateHTTPWebPagesRequest) returns (RPCUpdateSuccess);
// 更改访问日志配置
rpc updateHTTPAccessLog (UpdateHTTPAccessLogRequest) returns (RPCUpdateSuccess);
}
// 创建Web配置
@@ -94,3 +97,9 @@ message UpdateHTTPWebPagesRequest {
int64 webId = 1;
bytes pagesJSON = 2;
}
// 更改访问日志配置
message UpdateHTTPAccessLogRequest {
int64 webId = 1;
bytes accessLogJSON = 2;
}

View File

@@ -0,0 +1,74 @@
package serverconfigs
// 代理访问日志配置
type HTTPAccessLogConfig struct {
IsOn bool `yaml:"isOn" json:"isOn"`
Fields []int `yaml:"fields" json:"fields"` // 记录的字段
Status1 bool `yaml:"status1" json:"status1"` // 1xx
Status2 bool `yaml:"status2" json:"status2"` // 2xx
Status3 bool `yaml:"status3" json:"status3"` // 3xx
Status4 bool `yaml:"status4" json:"status4"` // 4xx
Status5 bool `yaml:"status5" json:"status5"` // 5xx
StorageOnly bool `yaml:"storageOnly" json:"storageOnly"` // 是否只输出到存储策略
StoragePolicies []int64 `yaml:"storagePolicies" json:"storagePolicies"` // 存储策略Ids
}
// 获取新对象
func NewHTTPAccessLogConfig() *HTTPAccessLogConfig {
return &HTTPAccessLogConfig{
IsOn: true,
Fields: []int{},
Status1: true,
Status2: true,
Status3: true,
Status4: true,
Status5: true,
}
}
// 校验
func (this *HTTPAccessLogConfig) Init() error {
return nil
}
// 判断是否应该记录
func (this *HTTPAccessLogConfig) Match(status int) bool {
s := status / 100
switch s {
case 1:
if !this.Status1 {
return false
}
case 2:
if !this.Status2 {
return false
}
case 3:
if !this.Status3 {
return false
}
case 4:
if !this.Status4 {
return false
}
case 5:
if !this.Status5 {
return false
}
}
return true
}
// 是否包含某个存储策略
func (this *HTTPAccessLogConfig) ContainsStoragePolicy(storagePolicyId int64) bool {
for _, s := range this.StoragePolicies {
if s == storagePolicyId {
return true
}
}
return false
}

View File

@@ -0,0 +1,45 @@
package serverconfigs
import (
"github.com/iwind/TeaGo/assert"
"testing"
)
func TestHTTPAccessLogConfig_Match(t *testing.T) {
a := assert.NewAssertion(t)
{
accessLog := NewHTTPAccessLogConfig()
a.IsNil(accessLog.Init())
a.IsTrue(accessLog.Match(100))
a.IsTrue(accessLog.Match(200))
a.IsTrue(accessLog.Match(300))
a.IsTrue(accessLog.Match(400))
a.IsTrue(accessLog.Match(500))
}
{
accessLog := NewHTTPAccessLogConfig()
accessLog.Status1 = false
accessLog.Status2 = false
a.IsNil(accessLog.Init())
a.IsFalse(accessLog.Match(100))
a.IsFalse(accessLog.Match(200))
a.IsTrue(accessLog.Match(300))
a.IsTrue(accessLog.Match(400))
a.IsTrue(accessLog.Match(500))
}
{
accessLog := NewHTTPAccessLogConfig()
accessLog.Status3 = false
accessLog.Status4 = false
accessLog.Status5 = false
a.IsNil(accessLog.Init())
a.IsTrue(accessLog.Match(100))
a.IsTrue(accessLog.Match(200))
a.IsFalse(accessLog.Match(300))
a.IsFalse(accessLog.Match(400))
a.IsFalse(accessLog.Match(500))
}
}

View File

@@ -0,0 +1,78 @@
package serverconfigs
import "github.com/iwind/TeaGo/maps"
type HTTPAccessLogField = int
const (
HTTPAccessLogFieldHeader HTTPAccessLogField = 1
HTTPAccessLogFieldSentHeader HTTPAccessLogField = 2
HTTPAccessLogFieldArg HTTPAccessLogField = 3
HTTPAccessLogFieldCookie HTTPAccessLogField = 4
HTTPAccessLogFieldExtend HTTPAccessLogField = 5
HTTPAccessLogFieldReferer HTTPAccessLogField = 6
HTTPAccessLogFieldUserAgent HTTPAccessLogField = 7
HTTPAccessLogFieldRequestBody HTTPAccessLogField = 8
HTTPAccessLogFieldResponseBody HTTPAccessLogField = 9
)
var HTTPAccessLogFieldsCodes = []HTTPAccessLogField{
HTTPAccessLogFieldHeader,
HTTPAccessLogFieldSentHeader,
HTTPAccessLogFieldArg,
HTTPAccessLogFieldCookie,
HTTPAccessLogFieldExtend,
HTTPAccessLogFieldReferer,
HTTPAccessLogFieldUserAgent,
HTTPAccessLogFieldRequestBody,
HTTPAccessLogFieldResponseBody,
}
var HTTPAccessLogDefaultFieldsCodes = []HTTPAccessLogField{
HTTPAccessLogFieldHeader,
HTTPAccessLogFieldSentHeader,
HTTPAccessLogFieldArg,
HTTPAccessLogFieldCookie,
HTTPAccessLogFieldExtend,
HTTPAccessLogFieldReferer,
HTTPAccessLogFieldUserAgent,
}
var HTTPAccessLogFields = []maps.Map{
{
"code": HTTPAccessLogFieldHeader,
"name": "请求Header列表",
},
{
"code": HTTPAccessLogFieldSentHeader,
"name": "响应Header列表",
},
{
"code": HTTPAccessLogFieldArg,
"name": "参数列表",
},
{
"code": HTTPAccessLogFieldCookie,
"name": "Cookie列表",
},
{
"code": HTTPAccessLogFieldExtend,
"name": "位置和浏览器分析",
},
{
"code": HTTPAccessLogFieldReferer,
"name": "请求来源",
},
{
"code": HTTPAccessLogFieldUserAgent,
"name": "终端信息",
},
{
"code": HTTPAccessLogFieldRequestBody,
"name": "请求Body",
},
{
"code": HTTPAccessLogFieldResponseBody,
"name": "响应Body",
},
}

View File

@@ -0,0 +1,112 @@
package serverconfigs
import (
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/configutils"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/logs"
"gopkg.in/yaml.v3"
"io/ioutil"
"os"
"strconv"
)
// 日志存储策略
// 存储在configs/accesslog.storage.$id.conf
type HTTPAccessLogStoragePolicy struct {
Id int64 `yaml:"id" json:"id"`
Name string `yaml:"name" json:"name"`
IsOn bool `yaml:"isOn" json:"isOn"`
Type string `yaml:"type" json:"type"` // 存储类型
Options map[string]interface{} `yaml:"options" json:"options"` // 存储选项
Conds []*shared.RequestCond `yaml:"conds" json:"conds"` // 请求条件
}
// 创建新策略
func NewHTTPAccessLogStoragePolicy() *HTTPAccessLogStoragePolicy {
return &HTTPAccessLogStoragePolicy{
IsOn: true,
}
}
// 从文件中加载策略
func NewAccessLogStoragePolicyFromId(id string) *HTTPAccessLogStoragePolicy {
filename := "accesslog.storage." + id + ".conf"
data, err := ioutil.ReadFile(Tea.ConfigFile(filename))
if err != nil {
logs.Error(err)
return nil
}
policy := NewHTTPAccessLogStoragePolicy()
err = yaml.Unmarshal(data, policy)
if err != nil {
logs.Error(err)
return nil
}
return policy
}
// 校验
func (this *HTTPAccessLogStoragePolicy) Init() error {
// cond
if len(this.Conds) > 0 {
for _, cond := range this.Conds {
err := cond.Init()
if err != nil {
return err
}
}
}
return nil
}
// 保存
func (this *HTTPAccessLogStoragePolicy) Save() error {
shared.Locker.Lock()
defer shared.Locker.Unlock()
data, err := yaml.Marshal(this)
if err != nil {
return err
}
filename := "accesslog.storage." + this.IdString() + ".conf"
return ioutil.WriteFile(Tea.ConfigFile(filename), data, 0666)
}
// 删除
func (this *HTTPAccessLogStoragePolicy) Delete() error {
filename := "accesslog.storage." + this.IdString() + ".conf"
return os.Remove(Tea.ConfigFile(filename))
}
// 匹配关键词
func (this *HTTPAccessLogStoragePolicy) MatchKeyword(keyword string) (matched bool, name string, tags []string) {
if configutils.MatchKeyword(this.Name, keyword) || configutils.MatchKeyword(this.Type, keyword) {
matched = true
name = this.Name
if len(this.Type) > 0 {
tags = []string{"类型:" + this.Type}
}
}
return
}
// 匹配条件
func (this *HTTPAccessLogStoragePolicy) MatchConds(formatter func(string) string) bool {
if len(this.Conds) == 0 {
return true
}
for _, cond := range this.Conds {
if !cond.Match(formatter) {
return false
}
}
return true
}
// 将ID转换为字符串
func (this *HTTPAccessLogStoragePolicy) IdString() string {
return strconv.FormatInt(this.Id, 10)
}

View File

@@ -0,0 +1,80 @@
package serverconfigs
import (
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/files"
"github.com/iwind/TeaGo/logs"
"gopkg.in/yaml.v3"
"io/ioutil"
)
var accessLogStoragePolicyListFilename = "accesslog.storage.list.conf"
// 获取共享的存储策略列表
func SharedHTTPAccessLogStoragePolicyList() *AccessLogStoragePolicyList {
path := Tea.ConfigFile(accessLogStoragePolicyListFilename)
file := files.NewFile(path)
if !file.Exists() {
return &AccessLogStoragePolicyList{}
}
reader, err := file.Reader()
if err != nil {
logs.Error(err)
return &AccessLogStoragePolicyList{}
}
defer reader.Close()
policyList := &AccessLogStoragePolicyList{}
err = reader.ReadYAML(policyList)
if err != nil {
logs.Error(err)
return policyList
}
return policyList
}
// 存储策略列表
type AccessLogStoragePolicyList struct {
Ids []string `yaml:"id" json:"id"`
}
// 添加策略ID
func (this *AccessLogStoragePolicyList) AddId(id string) {
this.Ids = append(this.Ids, id)
}
// 删除策略ID
func (this *AccessLogStoragePolicyList) RemoveId(id string) {
result := []string{}
for _, id2 := range this.Ids {
if id2 == id {
continue
}
result = append(result, id2)
}
this.Ids = result
}
// 保存
func (this *AccessLogStoragePolicyList) Save() error {
data, err := yaml.Marshal(this)
if err != nil {
return err
}
return ioutil.WriteFile(Tea.ConfigFile(accessLogStoragePolicyListFilename), data, 0666)
}
// 查找所有的策略列表
func (this *AccessLogStoragePolicyList) FindAllPolicies() []*HTTPAccessLogStoragePolicy {
shared.Locker.Lock()
defer shared.Locker.Unlock()
result := []*HTTPAccessLogStoragePolicy{}
for _, id := range this.Ids {
policy := NewAccessLogStoragePolicyFromId(id)
if policy != nil {
result = append(result, policy)
}
}
return result
}

View File

@@ -20,10 +20,10 @@ type HTTPCachePolicy struct {
IsOn bool `yaml:"isOn" json:"isOn"` // 是否开启 TODO
Name string `yaml:"name" json:"name"` // 名称
Key string `yaml:"key" json:"key"` // 每个缓存的Key规则里面可以有变量
Key string `yaml:"key" json:"key"` // 每个缓存的Key规则里面可以有变量
Capacity *shared.SizeCapacity `yaml:"capacity" json:"capacity"` // 最大内容容量
Life *shared.TimeDuration `yaml:"life" json:"life"` // 时间
Status []int `yaml:"status" json:"status"` // 缓存的状态码列表
Status []int `yaml:"status" json:"status"` // 缓存的状态码列表
MaxSize *shared.SizeCapacity `yaml:"maxSize" json:"maxSize"` // 能够请求的最大尺寸
SkipResponseCacheControlValues []string `yaml:"skipCacheControlValues" json:"skipCacheControlValues"` // 可以跳过的响应的Cache-Control值
@@ -75,7 +75,7 @@ func NewCachePolicyFromFile(file string) *HTTPCachePolicy {
}
// 校验
func (this *HTTPCachePolicy) Validate() error {
func (this *HTTPCachePolicy) Init() error {
var err error
this.maxSize = this.MaxSize.Bytes()
this.life = this.Life.Duration()
@@ -89,7 +89,7 @@ func (this *HTTPCachePolicy) Validate() error {
// cond
if len(this.Cond) > 0 {
for _, cond := range this.Cond {
err := cond.Validate()
err := cond.Init()
if err != nil {
return err
}

View File

@@ -16,4 +16,5 @@ type HTTPWebConfig struct {
MaxRequestBodySize string `yaml:"maxRequestBodySize" json:"maxRequestBodySize"` // 请求body最大尺寸
RequestHeaders *shared.HTTPHeaderPolicy `yaml:"requestHeaders" json:"requestHeaders"` // 请求Header
ResponseHeaders *shared.HTTPHeaderPolicy `yaml:"responseHeaders" json:"responseHeaders"` // 响应Header`
AccessLog *HTTPAccessLogConfig `yaml:"accessLog" json:"accessLog"` // 访问日志配置
}

View File

@@ -49,7 +49,7 @@ func NewRequestCond() *RequestCond {
}
// 校验配置
func (this *RequestCond) Validate() error {
func (this *RequestCond) Init() error {
this.isInt = RegexpDigitNumber.MatchString(this.Value)
this.isFloat = RegexpFloatNumber.MatchString(this.Value)

View File

@@ -19,7 +19,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorRegexp,
Value: "abc",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsFalse(cond.Match(func(format string) string {
return format
}))
@@ -31,7 +31,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorRegexp,
Value: "/\\w+",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(format string) string {
return format
}))
@@ -43,7 +43,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorRegexp,
Value: `^/article/\d+\.html$`,
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(format string) string {
return format
}))
@@ -55,7 +55,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorRegexp,
Value: "[",
}
a.IsNotNil(cond.Validate())
a.IsNotNil(cond.Init())
a.IsFalse(cond.Match(func(format string) string {
return format
}))
@@ -67,7 +67,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorNotRegexp,
Value: "abc",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(format string) string {
return format
}))
@@ -79,7 +79,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorNotRegexp,
Value: "/\\w+",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsFalse(cond.Match(func(format string) string {
return format
}))
@@ -91,7 +91,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorEqInt,
Value: "123",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -103,7 +103,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorEqInt,
Value: "123",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -115,7 +115,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorEqInt,
Value: "abc",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -127,7 +127,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorEqFloat,
Value: "123",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -139,7 +139,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorEqFloat,
Value: "123",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -151,7 +151,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorEqFloat,
Value: "123.12",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -163,7 +163,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorGtFloat,
Value: "1",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -175,7 +175,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorGtFloat,
Value: "125",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -187,7 +187,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorGteFloat,
Value: "125",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -199,7 +199,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorLtFloat,
Value: "127",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -211,7 +211,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorLteFloat,
Value: "127",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -223,7 +223,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorEqString,
Value: "125",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -235,7 +235,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorNeqString,
Value: "125",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -247,7 +247,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorNeqString,
Value: "127",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -259,7 +259,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorHasPrefix,
Value: "/hello",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -271,7 +271,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorHasPrefix,
Value: "/hello2",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -283,7 +283,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorHasSuffix,
Value: "world",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -295,7 +295,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorHasSuffix,
Value: "world/",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -307,7 +307,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorContainsString,
Value: "wo",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -319,7 +319,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorContainsString,
Value: "wr",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -331,7 +331,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorNotContainsString,
Value: "HELLO",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -343,7 +343,7 @@ func TestRequestCond_Compare1(t *testing.T) {
Operator: RequestCondOperatorNotContainsString,
Value: "hello",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -359,7 +359,7 @@ func TestRequestCond_IP(t *testing.T) {
Operator: RequestCondOperatorEqIP,
Value: "hello",
}
a.IsNotNil(cond.Validate())
a.IsNotNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -371,7 +371,7 @@ func TestRequestCond_IP(t *testing.T) {
Operator: RequestCondOperatorEqIP,
Value: "hello",
}
a.IsNotNil(cond.Validate())
a.IsNotNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -383,7 +383,7 @@ func TestRequestCond_IP(t *testing.T) {
Operator: RequestCondOperatorEqIP,
Value: "192.168.1.100",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -395,7 +395,7 @@ func TestRequestCond_IP(t *testing.T) {
Operator: RequestCondOperatorGtIP,
Value: "192.168.1.90",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -407,7 +407,7 @@ func TestRequestCond_IP(t *testing.T) {
Operator: RequestCondOperatorGteIP,
Value: "192.168.1.90",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -419,7 +419,7 @@ func TestRequestCond_IP(t *testing.T) {
Operator: RequestCondOperatorLtIP,
Value: "192.168.1.90",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -431,7 +431,7 @@ func TestRequestCond_IP(t *testing.T) {
Operator: RequestCondOperatorLteIP,
Value: "192.168.1.90",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -443,7 +443,7 @@ func TestRequestCond_IP(t *testing.T) {
Operator: RequestCondOperatorIPRange,
Value: "192.168.0.90,",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -455,7 +455,7 @@ func TestRequestCond_IP(t *testing.T) {
Operator: RequestCondOperatorIPRange,
Value: "192.168.0.90,192.168.1.100",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -467,7 +467,7 @@ func TestRequestCond_IP(t *testing.T) {
Operator: RequestCondOperatorIPRange,
Value: ",192.168.1.100",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -479,7 +479,7 @@ func TestRequestCond_IP(t *testing.T) {
Operator: RequestCondOperatorIPRange,
Value: "192.168.0.90,192.168.1.99",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -491,7 +491,7 @@ func TestRequestCond_IP(t *testing.T) {
Operator: RequestCondOperatorIPRange,
Value: "192.168.0.90/24",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -503,7 +503,7 @@ func TestRequestCond_IP(t *testing.T) {
Operator: RequestCondOperatorIPRange,
Value: "192.168.0.90/18",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -515,7 +515,7 @@ func TestRequestCond_IP(t *testing.T) {
Operator: RequestCondOperatorIPRange,
Value: "a/18",
}
a.IsNotNil(cond.Validate())
a.IsNotNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -527,7 +527,7 @@ func TestRequestCond_IP(t *testing.T) {
Operator: RequestCondOperatorIPMod10,
Value: "6",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -539,7 +539,7 @@ func TestRequestCond_IP(t *testing.T) {
Operator: RequestCondOperatorIPMod100,
Value: "76",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -551,7 +551,7 @@ func TestRequestCond_IP(t *testing.T) {
Operator: RequestCondOperatorIPMod,
Value: "10,6",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -605,7 +605,7 @@ func TestRequestCond_In(t *testing.T) {
Operator: RequestCondOperatorIn,
Value: `a`,
}
a.IsNotNil(cond.Validate())
a.IsNotNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -617,7 +617,7 @@ func TestRequestCond_In(t *testing.T) {
Operator: RequestCondOperatorIn,
Value: `["a", "b"]`,
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -629,7 +629,7 @@ func TestRequestCond_In(t *testing.T) {
Operator: RequestCondOperatorNotIn,
Value: `["a", "b"]`,
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -641,7 +641,7 @@ func TestRequestCond_In(t *testing.T) {
Operator: RequestCondOperatorNotIn,
Value: `["a", "b"]`,
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -657,7 +657,7 @@ func TestRequestCond_File(t *testing.T) {
Operator: RequestCondOperatorFileExt,
Value: `["jpeg", "jpg", "png"]`,
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -669,7 +669,7 @@ func TestRequestCond_File(t *testing.T) {
Operator: RequestCondOperatorFileExt,
Value: `["jpeg", "jpg", "png"]`,
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -681,7 +681,7 @@ func TestRequestCond_File(t *testing.T) {
Operator: RequestCondOperatorFileExt,
Value: `["jpeg", "jpg", "png"]`,
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -692,7 +692,7 @@ func TestRequestCond_File(t *testing.T) {
Param: "a.png",
Operator: RequestCondOperatorFileExist,
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -703,7 +703,7 @@ func TestRequestCond_File(t *testing.T) {
Param: Tea.Root + "/README.md",
Operator: RequestCondOperatorFileExist,
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -714,7 +714,7 @@ func TestRequestCond_File(t *testing.T) {
Param: Tea.Root + "/README.md?v=1",
Operator: RequestCondOperatorFileExist,
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -725,7 +725,7 @@ func TestRequestCond_File(t *testing.T) {
Param: Tea.Root,
Operator: RequestCondOperatorFileExist,
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -736,7 +736,7 @@ func TestRequestCond_File(t *testing.T) {
Param: Tea.Root,
Operator: RequestCondOperatorFileExist,
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -747,7 +747,7 @@ func TestRequestCond_File(t *testing.T) {
Param: "a.png",
Operator: RequestCondOperatorFileNotExist,
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -758,7 +758,7 @@ func TestRequestCond_File(t *testing.T) {
Param: Tea.Root + "/README.md",
Operator: RequestCondOperatorFileNotExist,
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -774,7 +774,7 @@ func TestRequestCond_MimeType(t *testing.T) {
Operator: RequestCondOperatorFileMimeType,
Value: `["text/html"]`,
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -786,7 +786,7 @@ func TestRequestCond_MimeType(t *testing.T) {
Operator: RequestCondOperatorFileMimeType,
Value: `["text/*"]`,
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -798,7 +798,7 @@ func TestRequestCond_MimeType(t *testing.T) {
Operator: RequestCondOperatorFileMimeType,
Value: `["image/*"]`,
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -810,7 +810,7 @@ func TestRequestCond_MimeType(t *testing.T) {
Operator: RequestCondOperatorFileMimeType,
Value: `["text/html", "image/jpeg", "image/png"]`,
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -826,7 +826,7 @@ func TestRequestCond_Version(t *testing.T) {
Operator: RequestCondOperatorVersionRange,
Value: `1.0,1.1`,
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -838,7 +838,7 @@ func TestRequestCond_Version(t *testing.T) {
Operator: RequestCondOperatorVersionRange,
Value: `1.0,`,
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -850,7 +850,7 @@ func TestRequestCond_Version(t *testing.T) {
Operator: RequestCondOperatorVersionRange,
Value: `,1.1`,
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -862,7 +862,7 @@ func TestRequestCond_Version(t *testing.T) {
Operator: RequestCondOperatorVersionRange,
Value: `1.0,1.1`,
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -874,7 +874,7 @@ func TestRequestCond_Version(t *testing.T) {
Operator: RequestCondOperatorVersionRange,
Value: `1.0`,
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -886,7 +886,7 @@ func TestRequestCond_Version(t *testing.T) {
Operator: RequestCondOperatorVersionRange,
Value: `1.0`,
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -908,7 +908,7 @@ func TestRequestCond_Mod(t *testing.T) {
Operator: RequestCondOperatorMod,
Value: "1",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -920,7 +920,7 @@ func TestRequestCond_Mod(t *testing.T) {
Operator: RequestCondOperatorMod,
Value: "2",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsFalse(cond.Match(func(source string) string {
return source
}))
@@ -932,7 +932,7 @@ func TestRequestCond_Mod(t *testing.T) {
Operator: RequestCondOperatorMod,
Value: "3",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -944,7 +944,7 @@ func TestRequestCond_Mod(t *testing.T) {
Operator: RequestCondOperatorMod,
Value: "11,1",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -956,7 +956,7 @@ func TestRequestCond_Mod(t *testing.T) {
Operator: RequestCondOperatorMod,
Value: "11,3",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -968,7 +968,7 @@ func TestRequestCond_Mod(t *testing.T) {
Operator: RequestCondOperatorMod,
Value: "2,0",
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -980,7 +980,7 @@ func TestRequestCond_Mod(t *testing.T) {
Operator: RequestCondOperatorMod10,
Value: fmt.Sprintf("%d", i%10),
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))
@@ -992,7 +992,7 @@ func TestRequestCond_Mod(t *testing.T) {
Operator: RequestCondOperatorMod100,
Value: fmt.Sprintf("%d", i%100),
}
a.IsNil(cond.Validate())
a.IsNil(cond.Init())
a.IsTrue(cond.Match(func(source string) string {
return source
}))