diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..9364f38 --- /dev/null +++ b/go.mod @@ -0,0 +1,8 @@ +module go.wit.com/lib/protobuf/httppb + +go 1.24.1 + +require ( + go.wit.com/log v0.22.18 + google.golang.org/protobuf v1.36.9 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..53d99ea --- /dev/null +++ b/go.sum @@ -0,0 +1,8 @@ +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +go.wit.com/log v0.22.18 h1:wlpNjxrFBCcHrZxVURR6QE/9vrVOVDEWgoupS76YQns= +go.wit.com/log v0.22.18/go.mod h1:XE4lTfAibWgwBJksIk7u3IEJ8xcBvNhnlewYAQGj2Ew= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw= +google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU= diff --git a/httpRequest.marshal.pb.go b/httpRequest.marshal.pb.go new file mode 100644 index 0000000..db7969d --- /dev/null +++ b/httpRequest.marshal.pb.go @@ -0,0 +1,56 @@ +// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT. +// This file was autogenerated with autogenpb v0.0.87 2025-09-09_22:14:39_UTC +// go install go.wit.com/apps/autogenpb@latest +// +// define which structs (messages) you want to use in the .proto file +// Then sort.pb.go and marshal.pb.go files are autogenerated +// +// autogenpb uses it and has an example .proto file with instructions +// + +package httppb + +import ( + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/encoding/prototext" + "google.golang.org/protobuf/proto" +) + +// human readable JSON +func (v *HttpRequests) FormatJSON() string { + return protojson.Format(v) +} + +// marshal json +func (v *HttpRequests) MarshalJSON() ([]byte, error) { + return protojson.Marshal(v) +} + +// unmarshal json +func (v *HttpRequests) UnmarshalJSON(data []byte) error { + return protojson.Unmarshal(data, v) +} + +// apparently this isn't stable, but it's awesomely better +// https://protobuf.dev/reference/go/faq/#unstable-text +// it's brilliant for config files! +func (v *HttpRequests) FormatTEXT() string { + v.fixUuid() + return prototext.Format(v) +} + +// unmarshalTEXT. This reads the .text config file back in after the user edits it +func (v *HttpRequests) UnmarshalTEXT(data []byte) error { + return prototext.Unmarshal(data, v) +} + +// marshal to wire. This is called winning. +func (v *HttpRequests) Marshal() ([]byte, error) { + v.fixUuid() + return proto.Marshal(v) +} + +// unmarshal from wire. You have won. +func (v *HttpRequests) Unmarshal(data []byte) error { + return proto.Unmarshal(data, v) +} diff --git a/httpRequest.pb.go b/httpRequest.pb.go new file mode 100644 index 0000000..e736861 --- /dev/null +++ b/httpRequest.pb.go @@ -0,0 +1,427 @@ +// Code modified by go.wit.com/apps/autogenpb DO NOT EDIT. +// +// user defined Mutex locks were auto added +// +// autogenpb version & build time: v0.0.87 2025-09-09_22:14:39_UTC +// autogenpb auto generates Sort(), Unique() and Marshal() functions +// go install go.wit.com/apps/autogenpb@latest + +// Copyright 2025 WIT.COM Inc Licensed GPL 3.0 + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.33.0 +// protoc v3.21.12 +// source: httpRequest.proto + +package httppb // autogenpb changed the package name + +import ( + reflect "reflect" + sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" +) + +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) +) + +type HttpRequest struct { + sync.RWMutex // auto-added by go.wit.com/apps/autogenpb + + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Method string `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"` // The request method, e.g., "GET", "POST". + URL string `protobuf:"bytes,2,opt,name=URL,proto3" json:"URL,omitempty"` // The full URL of the request, including scheme, host, path, and query string. + Route string `protobuf:"bytes,3,opt,name=route,proto3" json:"route,omitempty"` // just the route: "/add/" or "/find/" + Proto string `protobuf:"bytes,4,opt,name=proto,proto3" json:"proto,omitempty"` // The protocol version, e.g., "HTTP/1.1", "HTTP/2.0". + Headers map[string]string `protobuf:"bytes,5,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // The map of request headers. Header names are case-insensitive, + IP string `protobuf:"bytes,6,opt,name=IP,proto3" json:"IP,omitempty"` // The remote IP address of the client, after resolving proxies. + Host string `protobuf:"bytes,7,opt,name=host,proto3" json:"host,omitempty"` // The host on which the URL is sought (www.wit.com) + Hostname string `protobuf:"bytes,8,opt,name=hostname,proto3" json:"hostname,omitempty"` // The hostname of the client if passed from the client (mylaptop.fun.me) + Namespace string `protobuf:"bytes,9,opt,name=namespace,proto3" json:"namespace,omitempty"` // This is the pb namespace ("go.wit.com/lib/protobuf/virtpb") + Ctime *timestamppb.Timestamp `protobuf:"bytes,10,opt,name=ctime,proto3" json:"ctime,omitempty"` // create time of the patch + ClientData []byte `protobuf:"bytes,11,opt,name=clientData,proto3" json:"clientData,omitempty"` // the client payload + ClientDataLen int64 `protobuf:"varint,12,opt,name=clientDataLen,proto3" json:"clientDataLen,omitempty"` // len(body) + ServerData []byte `protobuf:"bytes,13,opt,name=serverData,proto3" json:"serverData,omitempty"` // the server response + ServerDataLen int64 `protobuf:"varint,14,opt,name=serverDataLen,proto3" json:"serverDataLen,omitempty"` // len(data) + Logs []string `protobuf:"bytes,15,rep,name=logs,proto3" json:"logs,omitempty"` // use this to store whatever you want while the whole POST happens + UserAgent string `protobuf:"bytes,16,opt,name=userAgent,proto3" json:"userAgent,omitempty"` // client user-agent + Query map[string]string `protobuf:"bytes,17,rep,name=query,proto3" json:"query,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // r.URL.Query() + RemoteAddr string `protobuf:"bytes,18,opt,name=remoteAddr,proto3" json:"remoteAddr,omitempty"` // r.RemoteAddr +} + +func (x *HttpRequest) Reset() { + *x = HttpRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_httpRequest_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HttpRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HttpRequest) ProtoMessage() {} + +func (x *HttpRequest) ProtoReflect() protoreflect.Message { + mi := &file_httpRequest_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 HttpRequest.ProtoReflect.Descriptor instead. +func (*HttpRequest) Descriptor() ([]byte, []int) { + return file_httpRequest_proto_rawDescGZIP(), []int{0} +} + +func (x *HttpRequest) GetMethod() string { + if x != nil { + return x.Method + } + return "" +} + +func (x *HttpRequest) GetURL() string { + if x != nil { + return x.URL + } + return "" +} + +func (x *HttpRequest) GetRoute() string { + if x != nil { + return x.Route + } + return "" +} + +func (x *HttpRequest) GetProto() string { + if x != nil { + return x.Proto + } + return "" +} + +func (x *HttpRequest) GetHeaders() map[string]string { + if x != nil { + return x.Headers + } + return nil +} + +func (x *HttpRequest) GetIP() string { + if x != nil { + return x.IP + } + return "" +} + +func (x *HttpRequest) GetHost() string { + if x != nil { + return x.Host + } + return "" +} + +func (x *HttpRequest) GetHostname() string { + if x != nil { + return x.Hostname + } + return "" +} + +func (x *HttpRequest) GetNamespace() string { + if x != nil { + return x.Namespace + } + return "" +} + +func (x *HttpRequest) GetCtime() *timestamppb.Timestamp { + if x != nil { + return x.Ctime + } + return nil +} + +func (x *HttpRequest) GetClientData() []byte { + if x != nil { + return x.ClientData + } + return nil +} + +func (x *HttpRequest) GetClientDataLen() int64 { + if x != nil { + return x.ClientDataLen + } + return 0 +} + +func (x *HttpRequest) GetServerData() []byte { + if x != nil { + return x.ServerData + } + return nil +} + +func (x *HttpRequest) GetServerDataLen() int64 { + if x != nil { + return x.ServerDataLen + } + return 0 +} + +func (x *HttpRequest) GetLogs() []string { + if x != nil { + return x.Logs + } + return nil +} + +func (x *HttpRequest) GetUserAgent() string { + if x != nil { + return x.UserAgent + } + return "" +} + +func (x *HttpRequest) GetQuery() map[string]string { + if x != nil { + return x.Query + } + return nil +} + +func (x *HttpRequest) GetRemoteAddr() string { + if x != nil { + return x.RemoteAddr + } + return "" +} + +type HttpRequests struct { + sync.RWMutex // auto-added by go.wit.com/apps/autogenpb + + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` // `autogenpb:uuid:1524ed43-e57d-4bf9-9449-1cdfdc498605` + Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` // `autogenpb:version:v0.0.1` + HttpRequests []*HttpRequest `protobuf:"bytes,3,rep,name=HttpRequests,proto3" json:"HttpRequests,omitempty"` // THIS MUST BE HttpRequest and then HttpRequests +} + +func (x *HttpRequests) Reset() { + *x = HttpRequests{} + if protoimpl.UnsafeEnabled { + mi := &file_httpRequest_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HttpRequests) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HttpRequests) ProtoMessage() {} + +func (x *HttpRequests) ProtoReflect() protoreflect.Message { + mi := &file_httpRequest_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 HttpRequests.ProtoReflect.Descriptor instead. +func (*HttpRequests) Descriptor() ([]byte, []int) { + return file_httpRequest_proto_rawDescGZIP(), []int{1} +} + +func (x *HttpRequests) GetUuid() string { + if x != nil { + return x.Uuid + } + return "" +} + +func (x *HttpRequests) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +func (x *HttpRequests) GetHttpRequests() []*HttpRequest { + if x != nil { + return x.HttpRequests + } + return nil +} + +var File_httpRequest_proto protoreflect.FileDescriptor + +var file_httpRequest_proto_rawDesc = []byte{ + 0x0a, 0x11, 0x68, 0x74, 0x74, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x68, 0x74, 0x74, 0x70, 0x70, 0x62, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb9, 0x05, 0x0a, + 0x0b, 0x48, 0x74, 0x74, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, + 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, + 0x74, 0x68, 0x6f, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x55, 0x52, 0x4c, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x55, 0x52, 0x4c, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x3a, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x05, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x70, 0x62, 0x2e, 0x48, 0x74, 0x74, + 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x0e, + 0x0a, 0x02, 0x49, 0x50, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x50, 0x12, 0x12, + 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, + 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x08, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, + 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x30, 0x0a, 0x05, + 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x1e, + 0x0a, 0x0a, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x44, 0x61, 0x74, 0x61, 0x18, 0x0b, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x0a, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x44, 0x61, 0x74, 0x61, 0x12, 0x24, + 0x0a, 0x0d, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x44, 0x61, 0x74, 0x61, 0x4c, 0x65, 0x6e, 0x18, + 0x0c, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x44, 0x61, 0x74, + 0x61, 0x4c, 0x65, 0x6e, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x44, 0x61, + 0x74, 0x61, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x44, 0x61, 0x74, 0x61, 0x12, 0x24, 0x0a, 0x0d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x44, 0x61, + 0x74, 0x61, 0x4c, 0x65, 0x6e, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x4c, 0x65, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x6f, + 0x67, 0x73, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x12, 0x1c, + 0x0a, 0x09, 0x75, 0x73, 0x65, 0x72, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x18, 0x10, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x12, 0x34, 0x0a, 0x05, + 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x11, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x68, 0x74, + 0x74, 0x70, 0x70, 0x62, 0x2e, 0x48, 0x74, 0x74, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x71, 0x75, 0x65, + 0x72, 0x79, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x41, 0x64, 0x64, 0x72, + 0x18, 0x12, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x41, 0x64, + 0x64, 0x72, 0x1a, 0x3a, 0x0a, 0x0c, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, + 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x38, + 0x0a, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, + 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, + 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x75, 0x0a, 0x0c, 0x48, 0x74, 0x74, 0x70, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x37, 0x0a, 0x0c, 0x48, 0x74, 0x74, 0x70, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x68, + 0x74, 0x74, 0x70, 0x70, 0x62, 0x2e, 0x48, 0x74, 0x74, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x52, 0x0c, 0x48, 0x74, 0x74, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_httpRequest_proto_rawDescOnce sync.Once + file_httpRequest_proto_rawDescData = file_httpRequest_proto_rawDesc +) + +func file_httpRequest_proto_rawDescGZIP() []byte { + file_httpRequest_proto_rawDescOnce.Do(func() { + file_httpRequest_proto_rawDescData = protoimpl.X.CompressGZIP(file_httpRequest_proto_rawDescData) + }) + return file_httpRequest_proto_rawDescData +} + +var file_httpRequest_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_httpRequest_proto_goTypes = []interface{}{ + (*HttpRequest)(nil), // 0: httppb.HttpRequest + (*HttpRequests)(nil), // 1: httppb.HttpRequests + nil, // 2: httppb.HttpRequest.HeadersEntry + nil, // 3: httppb.HttpRequest.QueryEntry + (*timestamppb.Timestamp)(nil), // 4: google.protobuf.Timestamp +} +var file_httpRequest_proto_depIdxs = []int32{ + 2, // 0: httppb.HttpRequest.headers:type_name -> httppb.HttpRequest.HeadersEntry + 4, // 1: httppb.HttpRequest.ctime:type_name -> google.protobuf.Timestamp + 3, // 2: httppb.HttpRequest.query:type_name -> httppb.HttpRequest.QueryEntry + 0, // 3: httppb.HttpRequests.HttpRequests:type_name -> httppb.HttpRequest + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_httpRequest_proto_init() } +func file_httpRequest_proto_init() { + if File_httpRequest_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_httpRequest_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HttpRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_httpRequest_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HttpRequests); 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_httpRequest_proto_rawDesc, + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_httpRequest_proto_goTypes, + DependencyIndexes: file_httpRequest_proto_depIdxs, + MessageInfos: file_httpRequest_proto_msgTypes, + }.Build() + File_httpRequest_proto = out.File + file_httpRequest_proto_rawDesc = nil + file_httpRequest_proto_goTypes = nil + file_httpRequest_proto_depIdxs = nil +} diff --git a/httpRequest.sort.pb.go b/httpRequest.sort.pb.go new file mode 100644 index 0000000..caea73a --- /dev/null +++ b/httpRequest.sort.pb.go @@ -0,0 +1,188 @@ +// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT. +// This file was autogenerated with autogenpb v0.0.87 2025-09-09_22:14:39_UTC +// go install go.wit.com/apps/autogenpb@latest +// +// define which structs (messages) you want to use in the .proto file +// Then sort.pb.go and marshal.pb.go files are autogenerated +// +// autogenpb uses it and has an example .proto file with instructions +// + +package httppb + +import ( + "fmt" + "iter" + "sync" + + "google.golang.org/protobuf/proto" +) + +// a simple global lock +var httpRequestMu sync.RWMutex + +func (x *HttpRequests) fixUuid() { + if x == nil { + return + } + if x.Uuid == "1524ed43-e57d-4bf9-9449-1cdfdc498605" { + return + } + x.Uuid = "1524ed43-e57d-4bf9-9449-1cdfdc498605" + x.Version = "v0.0.1 go.wit.com/lib/protobuf/httppb" +} + +func NewHttpRequests() *HttpRequests { + x := new(HttpRequests) + x.Uuid = "1524ed43-e57d-4bf9-9449-1cdfdc498605" + x.Version = "v0.0.1 go.wit.com/lib/protobuf/httppb" + return x +} + +// START SORT + +// DEFINE THE HttpRequests SCANNER. +// itializes a new scanner. +func newHttpRequestsScanner(things []*HttpRequests) *HttpRequestsScanner { + return &HttpRequestsScanner{things: things} +} + +type HttpRequestsScanner struct { + sync.Mutex + + things []*HttpRequests + index int +} + +func (it *HttpRequestsScanner) Scan() bool { + if it.index >= len(it.things) { + return false + } + it.Lock() + it.index++ + it.Unlock() + return true +} + +// Next() returns the next thing in the array +func (it *HttpRequestsScanner) Next() *HttpRequests { + if it.things[it.index-1] == nil { + fmt.Println("Next() error in HttpRequestsScanner", it.index) + } + return it.things[it.index-1] +} + +// END DEFINE THE SCANNER + +// DEFINE THE HttpRequest SCANNER. +// itializes a new scanner. +func newHttpRequestScanner(things []*HttpRequest) *HttpRequestScanner { + return &HttpRequestScanner{things: things} +} + +type HttpRequestScanner struct { + sync.Mutex + + things []*HttpRequest + index int +} + +func (it *HttpRequestScanner) Scan() bool { + if it.index >= len(it.things) { + return false + } + it.Lock() + it.index++ + it.Unlock() + return true +} + +// Next() returns the next thing in the array +func (it *HttpRequestScanner) Next() *HttpRequest { + if it.things[it.index-1] == nil { + fmt.Println("Next() error in HttpRequestScanner", it.index) + } + return it.things[it.index-1] +} + +// END DEFINE THE SCANNER + +// safely returns a slice of pointers to the FRUIT protobufs +func (x *HttpRequests) allHttpRequests() []*HttpRequest { + x.RLock() + defer x.RUnlock() + + // Create a new slice to hold pointers to each FRUIT + var tmp []*HttpRequest + tmp = make([]*HttpRequest, len(x.HttpRequests)) + for i, p := range x.HttpRequests { + tmp[i] = p // Copy pointers for safe iteration + } + + return tmp +} + +// safely returns a slice of pointers to the HttpRequest protobufs +func (x *HttpRequests) selectAllHttpRequests() []*HttpRequest { + x.RLock() + defer x.RUnlock() + + // Create a new slice to hold pointers to each HttpRequest + var tmp []*HttpRequest + tmp = make([]*HttpRequest, len(x.HttpRequests)) + for i, p := range x.HttpRequests { + tmp[i] = p // Copy pointers for safe iteration + } + + return tmp +} + +// END SORT + +func (x *HttpRequests) Len() int { + x.RLock() + defer x.RUnlock() + + return len(x.HttpRequests) +} + +// a Append() shortcut (that does Clone() with a mutex) notsure if it really works +func (x *HttpRequests) Append(y *HttpRequest) { + x.Lock() + defer x.Unlock() + + x.HttpRequests = append(x.HttpRequests, proto.Clone(y).(*HttpRequest)) +} + +func (x *HttpRequests) All() *HttpRequestScanner { + HttpRequestPointers := x.selectAllHttpRequests() + + scanner := newHttpRequestScanner(HttpRequestPointers) + return scanner +} + +// Iterate 'for x := range' syntax using the awesome golang 1.24 'iter' +func (x *HttpRequests) IterAll() iter.Seq[*HttpRequest] { + items := x.selectAllHttpRequests() + // log.Println("Made All() Iter.Seq[] with length", len(items)) + return func(yield func(*HttpRequest) bool) { + for _, v := range items { + if !yield(v) { + return + } + } + } +} +func (x *HttpRequests) Delete(y *HttpRequest) bool { + x.Lock() + defer x.Unlock() + + for i, _ := range x.HttpRequests { + if x.HttpRequests[i] == y { + x.HttpRequests[i] = x.HttpRequests[len(x.HttpRequests)-1] + x.HttpRequests = x.HttpRequests[:len(x.HttpRequests)-1] + return true + } + } + return false +}