gitpb/repo.http.pb.go

57 lines
1.4 KiB
Go

// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT.
// This file was autogenerated with autogenpb v0.5.3-11-g737c5b7 2025.09.16_2337
// 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 gitpb
import (
"net/http"
"path/filepath"
"go.wit.com/lib/protobuf/httppb"
)
// START HTTP
func (p *Repos) SendReply(w http.ResponseWriter, reqPB *httppb.HttpRequest) error {
data, err := p.Marshal()
if err != nil {
// reqPB.Errors = append(reqPB.Errors, log.Sprintf(, err))
}
if len(data) == 0 {
// reqPB.Errors = append(reqPB.Errors, "Patches PB data was nil/emtpy without Marsha() error")
return nil
}
_, err = w.Write(data)
if err != nil {
// reqPB.Errors = append(reqPB.Errors, log.Sprintf(, i, err))
}
return err
}
// Marshal protobuf, then http POST, then Unmarshal() to protobuf again
func (p *Repos) HttpPost(baseURL string, route string) (*Repos, *httppb.HttpRequest, error) {
data, err := p.Marshal()
if err != nil {
return nil, nil, err
}
tmp := filepath.Join("repos", route)
reqPB, err := httppb.DoPost(baseURL, tmp, data)
if reqPB == nil {
return nil, nil, err
}
newpb := new(Repos)
err = newpb.Unmarshal(reqPB.ServerData)
return newpb, reqPB, err
}
// END HTTP