diff --git a/pkg/rpc/pb/service_http_page.pb.go b/pkg/rpc/pb/service_http_page.pb.go index 3fa72d4..62ae8a4 100644 --- a/pkg/rpc/pb/service_http_page.pb.go +++ b/pkg/rpc/pb/service_http_page.pb.go @@ -36,7 +36,9 @@ type CreateHTTPPageRequest struct { unknownFields protoimpl.UnknownFields StatusList []string `protobuf:"bytes,1,rep,name=statusList,proto3" json:"statusList,omitempty"` + BodyType string `protobuf:"bytes,5,opt,name=bodyType,proto3" json:"bodyType,omitempty"` Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` + Body string `protobuf:"bytes,4,opt,name=body,proto3" json:"body,omitempty"` NewStatus int32 `protobuf:"varint,3,opt,name=newStatus,proto3" json:"newStatus,omitempty"` } @@ -79,6 +81,13 @@ func (x *CreateHTTPPageRequest) GetStatusList() []string { return nil } +func (x *CreateHTTPPageRequest) GetBodyType() string { + if x != nil { + return x.BodyType + } + return "" +} + func (x *CreateHTTPPageRequest) GetUrl() string { if x != nil { return x.Url @@ -86,6 +95,13 @@ func (x *CreateHTTPPageRequest) GetUrl() string { return "" } +func (x *CreateHTTPPageRequest) GetBody() string { + if x != nil { + return x.Body + } + return "" +} + func (x *CreateHTTPPageRequest) GetNewStatus() int32 { if x != nil { return x.NewStatus @@ -148,7 +164,9 @@ type UpdateHTTPPageRequest struct { PageId int64 `protobuf:"varint,1,opt,name=pageId,proto3" json:"pageId,omitempty"` StatusList []string `protobuf:"bytes,2,rep,name=statusList,proto3" json:"statusList,omitempty"` + BodyType string `protobuf:"bytes,6,opt,name=bodyType,proto3" json:"bodyType,omitempty"` Url string `protobuf:"bytes,3,opt,name=url,proto3" json:"url,omitempty"` + Body string `protobuf:"bytes,5,opt,name=body,proto3" json:"body,omitempty"` NewStatus int32 `protobuf:"varint,4,opt,name=newStatus,proto3" json:"newStatus,omitempty"` } @@ -198,6 +216,13 @@ func (x *UpdateHTTPPageRequest) GetStatusList() []string { return nil } +func (x *UpdateHTTPPageRequest) GetBodyType() string { + if x != nil { + return x.BodyType + } + return "" +} + func (x *UpdateHTTPPageRequest) GetUrl() string { if x != nil { return x.Url @@ -205,6 +230,13 @@ func (x *UpdateHTTPPageRequest) GetUrl() string { return "" } +func (x *UpdateHTTPPageRequest) GetBody() string { + if x != nil { + return x.Body + } + return "" +} + func (x *UpdateHTTPPageRequest) GetNewStatus() int32 { if x != nil { return x.NewStatus @@ -313,50 +345,56 @@ var file_service_http_page_proto_rawDesc = []byte{ 0x0a, 0x17, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x68, 0x74, 0x74, 0x70, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x19, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x72, 0x70, 0x63, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x67, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x18, - 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4c, 0x69, 0x73, - 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, - 0x75, 0x72, 0x6c, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x65, 0x77, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x6e, 0x65, 0x77, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x22, 0x30, 0x0a, 0x16, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x50, - 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x70, - 0x61, 0x67, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x70, 0x61, 0x67, - 0x65, 0x49, 0x64, 0x22, 0x7f, 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, - 0x50, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, - 0x70, 0x61, 0x67, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x70, 0x61, - 0x67, 0x65, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4c, 0x69, - 0x73, 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x4c, 0x69, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x65, 0x77, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x6e, 0x65, 0x77, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x22, 0x3a, 0x0a, 0x20, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, - 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50, 0x50, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x67, 0x65, - 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x70, 0x61, 0x67, 0x65, 0x49, 0x64, - 0x22, 0x3f, 0x0a, 0x21, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, - 0x54, 0x54, 0x50, 0x50, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x67, 0x65, 0x4a, 0x53, 0x4f, - 0x4e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x4a, 0x53, 0x4f, - 0x4e, 0x32, 0x81, 0x02, 0x0a, 0x0f, 0x48, 0x54, 0x54, 0x50, 0x50, 0x61, 0x67, 0x65, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x47, 0x0a, 0x0e, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x48, - 0x54, 0x54, 0x50, 0x50, 0x61, 0x67, 0x65, 0x12, 0x19, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, + 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x97, 0x01, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x48, 0x54, - 0x54, 0x50, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, - 0x0a, 0x0e, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x50, 0x61, 0x67, 0x65, - 0x12, 0x19, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, - 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x70, 0x62, - 0x2e, 0x52, 0x50, 0x43, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x68, 0x0a, 0x19, 0x66, - 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50, 0x50, 0x61, - 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x24, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, - 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50, 0x50, 0x61, 0x67, - 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, - 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, - 0x54, 0x54, 0x50, 0x50, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4c, 0x69, 0x73, 0x74, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4c, 0x69, + 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x6f, 0x64, 0x79, 0x54, 0x79, 0x70, 0x65, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x62, 0x6f, 0x64, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x10, + 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, + 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x62, 0x6f, 0x64, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x65, 0x77, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x6e, 0x65, 0x77, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x22, 0x30, 0x0a, 0x16, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, + 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, + 0x70, 0x61, 0x67, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x70, 0x61, + 0x67, 0x65, 0x49, 0x64, 0x22, 0xaf, 0x01, 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, + 0x54, 0x54, 0x50, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, + 0x0a, 0x06, 0x70, 0x61, 0x67, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, + 0x70, 0x61, 0x67, 0x65, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x4c, 0x69, 0x73, 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x6f, 0x64, 0x79, 0x54, 0x79, + 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x62, 0x6f, 0x64, 0x79, 0x54, 0x79, + 0x70, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x75, 0x72, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x65, 0x77, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x6e, 0x65, 0x77, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x3a, 0x0a, 0x20, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, + 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50, 0x50, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, + 0x67, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x70, 0x61, 0x67, 0x65, + 0x49, 0x64, 0x22, 0x3f, 0x0a, 0x21, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, + 0x64, 0x48, 0x54, 0x54, 0x50, 0x50, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x67, 0x65, 0x4a, + 0x53, 0x4f, 0x4e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x4a, + 0x53, 0x4f, 0x4e, 0x32, 0x81, 0x02, 0x0a, 0x0f, 0x48, 0x54, 0x54, 0x50, 0x50, 0x61, 0x67, 0x65, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x47, 0x0a, 0x0e, 0x63, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x48, 0x54, 0x54, 0x50, 0x50, 0x61, 0x67, 0x65, 0x12, 0x19, 0x2e, 0x70, 0x62, 0x2e, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x48, 0x54, 0x54, 0x50, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x3b, 0x0a, 0x0e, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x50, 0x61, + 0x67, 0x65, 0x12, 0x19, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, + 0x54, 0x50, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, + 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x68, 0x0a, + 0x19, 0x66, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50, + 0x50, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x24, 0x2e, 0x70, 0x62, 0x2e, + 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50, 0x50, + 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x25, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, + 0x64, 0x48, 0x54, 0x54, 0x50, 0x50, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 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 ( diff --git a/pkg/rpc/protos/service_http_page.proto b/pkg/rpc/protos/service_http_page.proto index e2d4e8a..ca808c8 100644 --- a/pkg/rpc/protos/service_http_page.proto +++ b/pkg/rpc/protos/service_http_page.proto @@ -19,7 +19,9 @@ service HTTPPageService { // 创建Page message CreateHTTPPageRequest { repeated string statusList = 1; + string bodyType = 5; string url = 2; + string body = 4; int32 newStatus = 3; } @@ -31,7 +33,9 @@ message CreateHTTPPageResponse { message UpdateHTTPPageRequest { int64 pageId = 1; repeated string statusList = 2; + string bodyType = 6; string url = 3; + string body = 5; int32 newStatus = 4; } diff --git a/pkg/serverconfigs/http_page_config.go b/pkg/serverconfigs/http_page_config.go index 00677cd..5b2bc0b 100644 --- a/pkg/serverconfigs/http_page_config.go +++ b/pkg/serverconfigs/http_page_config.go @@ -1,27 +1,31 @@ package serverconfigs -// 特殊页面配置 +import "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" + +// HTTPPageConfig 特殊页面配置 // TODO 需要支持Header定义 -// TODO 需要可以自定义文本 type HTTPPageConfig struct { Id int64 `yaml:"id" json:"id"` // 页面ID IsOn bool `yaml:"isOn" json:"isOn"` // 是否开启 TODO Status []string `yaml:"status" json:"status"` // 响应支持40x, 50x, 3x2 - URL string `yaml:"url" json:"url"` // URL NewStatus int `yaml:"newStatus" json:"newStatus"` // 新状态码 + BodyType shared.BodyType `yaml:"bodyType" json:"bodyType"` // 内容类型 + URL string `yaml:"url" json:"url"` // URL + Body string `yaml:"body" json:"body"` // 输出的内容 + statusList []*WildcardStatus hasStatusList bool } -// 获取新对象 +// NewHTTPPageConfig 获取新对象 func NewHTTPPageConfig() *HTTPPageConfig { return &HTTPPageConfig{ IsOn: true, } } -// 校验 +// Init 校验 func (this *HTTPPageConfig) Init() error { this.statusList = []*WildcardStatus{} for _, s := range this.Status { @@ -31,7 +35,7 @@ func (this *HTTPPageConfig) Init() error { return nil } -// 检查是否匹配 +// Match 检查是否匹配 func (this *HTTPPageConfig) Match(status int) bool { if !this.hasStatusList { return false diff --git a/pkg/serverconfigs/http_shutdown_config.go b/pkg/serverconfigs/http_shutdown_config.go index 8e4f02c..7361f01 100644 --- a/pkg/serverconfigs/http_shutdown_config.go +++ b/pkg/serverconfigs/http_shutdown_config.go @@ -1,18 +1,23 @@ package serverconfigs -// 关闭页面配置 -type HTTPShutdownConfig struct { - IsPrior bool `yaml:"isPrior" json:"isPrior"` - IsOn bool `yaml:"isOn" json:"isOn"` - URL string `yaml:"url" json:"url"` - Status int `yaml:"status" json:"status"` +import "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" + +// HTTPShutdownConfig 关闭页面配置 +type HTTPShutdownConfig struct { + IsPrior bool `yaml:"isPrior" json:"isPrior"` + IsOn bool `yaml:"isOn" json:"isOn"` + + BodyType shared.BodyType `yaml:"bodyType" json:"bodyType"` // 内容类型 + URL string `yaml:"url" json:"url"` // URL + Body string `yaml:"body" json:"body"` // 输出的内容 + + Status int `yaml:"status" json:"status"` - // TODO 可以自定义文本 // TODO 可以自定义Content-Type // TODO 可以设置是否立即断开与客户端的连接 } -// 校验 +// Init 校验 func (this *HTTPShutdownConfig) Init() error { return nil } diff --git a/pkg/serverconfigs/shared/body_type.go b/pkg/serverconfigs/shared/body_type.go new file mode 100644 index 0000000..4775950 --- /dev/null +++ b/pkg/serverconfigs/shared/body_type.go @@ -0,0 +1,23 @@ +// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved. + +package shared + +type BodyType = string + +const ( + BodyTypeURL BodyType = "url" + BodyTypeHTML BodyType = "html" +) + +func FindAllBodyTypes() []*Definition { + return []*Definition{ + { + Name: "读取URL", + Code: BodyTypeURL, + }, + { + Name: "HTML", + Code: BodyTypeHTML, + }, + } +}