diff --git a/pkg/rpc/pb/model_http_gzip.pb.go b/pkg/rpc/pb/model_http_gzip.pb.go index 3409c46..b132643 100644 --- a/pkg/rpc/pb/model_http_gzip.pb.go +++ b/pkg/rpc/pb/model_http_gzip.pb.go @@ -30,11 +30,12 @@ type HTTPGzip struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - IsOn bool `protobuf:"varint,2,opt,name=isOn,proto3" json:"isOn,omitempty"` - Level int32 `protobuf:"varint,3,opt,name=level,proto3" json:"level,omitempty"` - MinLength *SizeCapacity `protobuf:"bytes,4,opt,name=minLength,proto3" json:"minLength,omitempty"` - MaxLength *SizeCapacity `protobuf:"bytes,5,opt,name=maxLength,proto3" json:"maxLength,omitempty"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + IsOn bool `protobuf:"varint,2,opt,name=isOn,proto3" json:"isOn,omitempty"` + Level int32 `protobuf:"varint,3,opt,name=level,proto3" json:"level,omitempty"` + MinLength *SizeCapacity `protobuf:"bytes,4,opt,name=minLength,proto3" json:"minLength,omitempty"` + MaxLength *SizeCapacity `protobuf:"bytes,5,opt,name=maxLength,proto3" json:"maxLength,omitempty"` + CondGroupsJSON []byte `protobuf:"bytes,6,opt,name=CondGroupsJSON,proto3" json:"CondGroupsJSON,omitempty"` } func (x *HTTPGzip) Reset() { @@ -104,13 +105,20 @@ func (x *HTTPGzip) GetMaxLength() *SizeCapacity { return nil } +func (x *HTTPGzip) GetCondGroupsJSON() []byte { + if x != nil { + return x.CondGroupsJSON + } + return nil +} + var File_model_http_gzip_proto protoreflect.FileDescriptor var file_model_http_gzip_proto_rawDesc = []byte{ 0x0a, 0x15, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x68, 0x74, 0x74, 0x70, 0x5f, 0x67, 0x7a, 0x69, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x19, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x5f, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa4, 0x01, 0x0a, 0x08, 0x48, 0x54, 0x54, 0x50, 0x47, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xcc, 0x01, 0x0a, 0x08, 0x48, 0x54, 0x54, 0x50, 0x47, 0x7a, 0x69, 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, @@ -120,8 +128,11 @@ var file_model_http_gzip_proto_rawDesc = []byte{ 0x74, 0x79, 0x52, 0x09, 0x6d, 0x69, 0x6e, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x2e, 0x0a, 0x09, 0x6d, 0x61, 0x78, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x69, 0x7a, 0x65, 0x43, 0x61, 0x70, 0x61, 0x63, 0x69, - 0x74, 0x79, 0x52, 0x09, 0x6d, 0x61, 0x78, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x42, 0x06, 0x5a, - 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x79, 0x52, 0x09, 0x6d, 0x61, 0x78, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x26, 0x0a, + 0x0e, 0x43, 0x6f, 0x6e, 0x64, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x43, 0x6f, 0x6e, 0x64, 0x47, 0x72, 0x6f, 0x75, 0x70, + 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/rpc/pb/service_http_gzip.pb.go b/pkg/rpc/pb/service_http_gzip.pb.go index b810da5..aa3e18f 100644 --- a/pkg/rpc/pb/service_http_gzip.pb.go +++ b/pkg/rpc/pb/service_http_gzip.pb.go @@ -35,9 +35,10 @@ type CreateHTTPGzipRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Level int32 `protobuf:"varint,1,opt,name=level,proto3" json:"level,omitempty"` - MinLength *SizeCapacity `protobuf:"bytes,2,opt,name=minLength,proto3" json:"minLength,omitempty"` - MaxLength *SizeCapacity `protobuf:"bytes,3,opt,name=maxLength,proto3" json:"maxLength,omitempty"` + Level int32 `protobuf:"varint,1,opt,name=level,proto3" json:"level,omitempty"` + MinLength *SizeCapacity `protobuf:"bytes,2,opt,name=minLength,proto3" json:"minLength,omitempty"` + MaxLength *SizeCapacity `protobuf:"bytes,3,opt,name=maxLength,proto3" json:"maxLength,omitempty"` + CondGroupsJSON []byte `protobuf:"bytes,4,opt,name=condGroupsJSON,proto3" json:"condGroupsJSON,omitempty"` } func (x *CreateHTTPGzipRequest) Reset() { @@ -93,6 +94,13 @@ func (x *CreateHTTPGzipRequest) GetMaxLength() *SizeCapacity { return nil } +func (x *CreateHTTPGzipRequest) GetCondGroupsJSON() []byte { + if x != nil { + return x.CondGroupsJSON + } + return nil +} + type CreateHTTPGzipResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -241,10 +249,11 @@ type UpdateHTTPGzipRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - GzipId int64 `protobuf:"varint,1,opt,name=gzipId,proto3" json:"gzipId,omitempty"` - Level int32 `protobuf:"varint,2,opt,name=level,proto3" json:"level,omitempty"` - MinLength *SizeCapacity `protobuf:"bytes,3,opt,name=minLength,proto3" json:"minLength,omitempty"` - MaxLength *SizeCapacity `protobuf:"bytes,4,opt,name=maxLength,proto3" json:"maxLength,omitempty"` + GzipId int64 `protobuf:"varint,1,opt,name=gzipId,proto3" json:"gzipId,omitempty"` + Level int32 `protobuf:"varint,2,opt,name=level,proto3" json:"level,omitempty"` + MinLength *SizeCapacity `protobuf:"bytes,3,opt,name=minLength,proto3" json:"minLength,omitempty"` + MaxLength *SizeCapacity `protobuf:"bytes,4,opt,name=maxLength,proto3" json:"maxLength,omitempty"` + CondGroupsJSON []byte `protobuf:"bytes,5,opt,name=condGroupsJSON,proto3" json:"condGroupsJSON,omitempty"` } func (x *UpdateHTTPGzipRequest) Reset() { @@ -307,6 +316,13 @@ func (x *UpdateHTTPGzipRequest) GetMaxLength() *SizeCapacity { return nil } +func (x *UpdateHTTPGzipRequest) GetCondGroupsJSON() []byte { + if x != nil { + return x.CondGroupsJSON + } + return nil +} + var File_service_http_gzip_proto protoreflect.FileDescriptor var file_service_http_gzip_proto_rawDesc = []byte{ @@ -314,7 +330,7 @@ var file_service_http_gzip_proto_rawDesc = []byte{ 0x7a, 0x69, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x19, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x5f, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x12, 0x72, 0x70, 0x63, 0x5f, 0x6d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8d, 0x01, 0x0a, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb5, 0x01, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x47, 0x7a, 0x69, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x2e, 0x0a, 0x09, @@ -323,28 +339,33 @@ var file_service_http_gzip_proto_rawDesc = []byte{ 0x79, 0x52, 0x09, 0x6d, 0x69, 0x6e, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x2e, 0x0a, 0x09, 0x6d, 0x61, 0x78, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x69, 0x7a, 0x65, 0x43, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, - 0x79, 0x52, 0x09, 0x6d, 0x61, 0x78, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x22, 0x30, 0x0a, 0x16, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x47, 0x7a, 0x69, 0x70, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x7a, 0x69, 0x70, 0x49, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x67, 0x7a, 0x69, 0x70, 0x49, 0x64, 0x22, 0x36, - 0x0a, 0x1c, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x47, 0x7a, 0x69, - 0x70, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, + 0x79, 0x52, 0x09, 0x6d, 0x61, 0x78, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x26, 0x0a, 0x0e, + 0x63, 0x6f, 0x6e, 0x64, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x63, 0x6f, 0x6e, 0x64, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, + 0x4a, 0x53, 0x4f, 0x4e, 0x22, 0x30, 0x0a, 0x16, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x48, 0x54, + 0x54, 0x50, 0x47, 0x7a, 0x69, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x7a, 0x69, 0x70, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, - 0x67, 0x7a, 0x69, 0x70, 0x49, 0x64, 0x22, 0x3b, 0x0a, 0x1d, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, + 0x67, 0x7a, 0x69, 0x70, 0x49, 0x64, 0x22, 0x36, 0x0a, 0x1c, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x47, 0x7a, 0x69, 0x70, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x67, 0x7a, 0x69, 0x70, 0x4a, - 0x53, 0x4f, 0x4e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x67, 0x7a, 0x69, 0x70, 0x4a, - 0x53, 0x4f, 0x4e, 0x22, 0xa5, 0x01, 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, - 0x54, 0x50, 0x47, 0x7a, 0x69, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, - 0x06, 0x67, 0x7a, 0x69, 0x70, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x67, - 0x7a, 0x69, 0x70, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x2e, 0x0a, 0x09, 0x6d, - 0x69, 0x6e, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, - 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x69, 0x7a, 0x65, 0x43, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, - 0x52, 0x09, 0x6d, 0x69, 0x6e, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x2e, 0x0a, 0x09, 0x6d, - 0x61, 0x78, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, - 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x69, 0x7a, 0x65, 0x43, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, - 0x52, 0x09, 0x6d, 0x61, 0x78, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x32, 0xff, 0x01, 0x0a, 0x0f, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x7a, 0x69, 0x70, 0x49, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x67, 0x7a, 0x69, 0x70, 0x49, 0x64, 0x22, 0x3b, + 0x0a, 0x1d, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x47, 0x7a, 0x69, + 0x70, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x1a, 0x0a, 0x08, 0x67, 0x7a, 0x69, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x08, 0x67, 0x7a, 0x69, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x22, 0xcd, 0x01, 0x0a, 0x15, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x47, 0x7a, 0x69, 0x70, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x7a, 0x69, 0x70, 0x49, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x67, 0x7a, 0x69, 0x70, 0x49, 0x64, 0x12, 0x14, 0x0a, + 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x65, + 0x76, 0x65, 0x6c, 0x12, 0x2e, 0x0a, 0x09, 0x6d, 0x69, 0x6e, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x69, 0x7a, 0x65, + 0x43, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x52, 0x09, 0x6d, 0x69, 0x6e, 0x4c, 0x65, 0x6e, + 0x67, 0x74, 0x68, 0x12, 0x2e, 0x0a, 0x09, 0x6d, 0x61, 0x78, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x69, 0x7a, 0x65, + 0x43, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x52, 0x09, 0x6d, 0x61, 0x78, 0x4c, 0x65, 0x6e, + 0x67, 0x74, 0x68, 0x12, 0x26, 0x0a, 0x0e, 0x63, 0x6f, 0x6e, 0x64, 0x47, 0x72, 0x6f, 0x75, 0x70, + 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x63, 0x6f, 0x6e, + 0x64, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x32, 0xff, 0x01, 0x0a, 0x0f, 0x48, 0x54, 0x54, 0x50, 0x47, 0x7a, 0x69, 0x70, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x47, 0x0a, 0x0e, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x47, 0x7a, 0x69, 0x70, 0x12, 0x19, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, diff --git a/pkg/rpc/protos/model_http_gzip.proto b/pkg/rpc/protos/model_http_gzip.proto index 5a5d9cc..4bb0164 100644 --- a/pkg/rpc/protos/model_http_gzip.proto +++ b/pkg/rpc/protos/model_http_gzip.proto @@ -11,4 +11,5 @@ message HTTPGzip { int32 level = 3; SizeCapacity minLength = 4; SizeCapacity maxLength = 5; + bytes CondGroupsJSON = 6; } \ No newline at end of file diff --git a/pkg/rpc/protos/service_http_gzip.proto b/pkg/rpc/protos/service_http_gzip.proto index 738a02a..91476dd 100644 --- a/pkg/rpc/protos/service_http_gzip.proto +++ b/pkg/rpc/protos/service_http_gzip.proto @@ -22,6 +22,7 @@ message CreateHTTPGzipRequest { int32 level = 1; SizeCapacity minLength = 2; SizeCapacity maxLength = 3; + bytes condGroupsJSON = 4; } message CreateHTTPGzipResponse { @@ -43,4 +44,5 @@ message UpdateHTTPGzipRequest { int32 level = 2; SizeCapacity minLength = 3; SizeCapacity maxLength = 4; + bytes condGroupsJSON = 5; } diff --git a/pkg/serverconfigs/http_gzip_config.go b/pkg/serverconfigs/http_gzip_config.go index a785a17..faab26f 100644 --- a/pkg/serverconfigs/http_gzip_config.go +++ b/pkg/serverconfigs/http_gzip_config.go @@ -2,7 +2,6 @@ package serverconfigs import ( "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" - "regexp" "strings" ) @@ -13,12 +12,12 @@ var ( // gzip配置 type HTTPGzipConfig struct { - Id int64 `yaml:"id" json:"id"` // ID - IsOn bool `yaml:"isOn" json:"isOn"` // 是否启用 - Level int8 `yaml:"level" json:"level"` // 1-9 - MinLength *shared.SizeCapacity `yaml:"minLength" json:"minLength"` // 最小压缩对象比如4m, 24k - MaxLength *shared.SizeCapacity `yaml:"minLength" json:"maxLength"` // 最大压缩对象 TODO 需要实现 - MimeTypes []string `yaml:"mimeTypes" json:"mimeTypes"` // 比如text/html, text/* // TODO 需要实现,可能需要用RequestConds替代 + Id int64 `yaml:"id" json:"id"` // ID + IsOn bool `yaml:"isOn" json:"isOn"` // 是否启用 + Level int8 `yaml:"level" json:"level"` // 1-9 + MinLength *shared.SizeCapacity `yaml:"minLength" json:"minLength"` // 最小压缩对象比如4m, 24k + MaxLength *shared.SizeCapacity `yaml:"maxLength" json:"maxLength"` // 最大压缩对象 TODO 需要实现 + CondGroups []*shared.HTTPRequestCondGroup `yaml:"condGroups" json:"condGroups"` // 匹配条件 minLength int64 mimeTypes []*MimeTypeRule @@ -30,30 +29,6 @@ func (this *HTTPGzipConfig) Init() error { this.minLength = this.MinLength.Bytes() } - if len(this.MimeTypes) == 0 { - this.MimeTypes = DefaultGzipMimeTypes - } - - this.mimeTypes = []*MimeTypeRule{} - for _, mimeType := range this.MimeTypes { - if strings.Contains(mimeType, "*") { - mimeType = regexp.QuoteMeta(mimeType) - mimeType = strings.Replace(mimeType, "\\*", ".*", -1) - reg, err := regexp.Compile("^" + mimeType + "$") - if err != nil { - return err - } - this.mimeTypes = append(this.mimeTypes, &MimeTypeRule{ - Value: mimeType, - Regexp: reg, - }) - } else { - this.mimeTypes = append(this.mimeTypes, &MimeTypeRule{ - Value: mimeType, - Regexp: nil, - }) - } - } return nil } diff --git a/pkg/serverconfigs/shared/http_request_cond.go b/pkg/serverconfigs/shared/http_request_cond.go index e9b1963..ace035d 100644 --- a/pkg/serverconfigs/shared/http_request_cond.go +++ b/pkg/serverconfigs/shared/http_request_cond.go @@ -18,19 +18,15 @@ import ( // 重写条件定义 type HTTPRequestCond struct { - Id string `yaml:"id" json:"id"` // ID - IsOn bool `yaml:"isOn" json:"isOn"` // 是否启用 + Type string `yaml:"type" json:"type"` // 类型,在特殊条件时使用 // 要测试的字符串 // 其中可以使用跟请求相关的参数,比如: // ${arg.name}, ${requestPath} Param string `yaml:"param" json:"param"` - // 运算符 - Operator RequestCondOperator `yaml:"operator" json:"operator"` - - // 对比 - Value string `yaml:"value" json:"value"` + Operator RequestCondOperator `yaml:"operator" json:"operator"` // 运算符 + Value string `yaml:"value" json:"value"` // 对比值 isInt bool isFloat bool diff --git a/pkg/serverconfigs/shared/http_request_cond_group.go b/pkg/serverconfigs/shared/http_request_cond_group.go index ee1cbdb..d36ce0f 100644 --- a/pkg/serverconfigs/shared/http_request_cond_group.go +++ b/pkg/serverconfigs/shared/http_request_cond_group.go @@ -2,10 +2,11 @@ package shared // 请求条件分组 type HTTPRequestCondGroup struct { - IsOn bool `yaml:"isOn" json:"isOn"` // 是否启用 - Connector string `yaml:"connector" json:"connector"` // 条件之间的关系 - Conds []*HTTPRequestCond `yaml:"conds" json:"conds"` // 条件列表 - IsReverse bool `yaml:"isReverse" json:"isReverse"` // 是否反向匹配 + IsOn bool `yaml:"isOn" json:"isOn"` // 是否启用 + Connector string `yaml:"connector" json:"connector"` // 条件之间的关系 + Conds []*HTTPRequestCond `yaml:"conds" json:"conds"` // 条件列表 + IsReverse bool `yaml:"isReverse" json:"isReverse"` // 是否反向匹配 + Description string `yaml:"description" json:"description"` // 说明 } // 初始化