diff options
| author | Jeff Carr <[email protected]> | 2025-09-08 04:34:43 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-09-08 04:34:43 -0500 |
| commit | da3244d2655a3711f20d2be62c8eeba3b8c0050f (patch) | |
| tree | 4428e9cad97dd186783ba8d2d07ba1a987e2fdad | |
| parent | 96cd7ffb2d219e0afe1079583d4667e75e0c7642 (diff) | |
much better standard autogen codev0.0.84
| -rw-r--r-- | generateHTTP.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/generateHTTP.go b/generateHTTP.go index 9cb53b3..0bf3b12 100644 --- a/generateHTTP.go +++ b/generateHTTP.go @@ -110,6 +110,25 @@ func httpSendReply(w io.Writer, FRUITS string) { } func httpCustom(w io.Writer, FRUITS string, fRUITS string, FRUIT string) { + fmt.Fprintln(w, "// Marshal protobuf, then http POST, then Unmarshal() to protobuf again") + fmt.Fprintln(w, "func (p *"+FRUITS+") HttpPost(baseURL string, route string) (*"+FRUITS+", *httppb.HttpRequest, error) {") + fmt.Fprintln(w, " data, err := p.Marshal()") + fmt.Fprintln(w, " if err != nil {") + fmt.Fprintln(w, " return nil, nil, err") + fmt.Fprintln(w, " }") + fmt.Fprintln(w, "") + fmt.Fprintln(w, " reqPB, err := httppb.DoPost(baseURL, route, data)") + fmt.Fprintln(w, " if reqPB == nil {") + fmt.Fprintln(w, " return nil, nil, err") + fmt.Fprintln(w, " }") + fmt.Fprintln(w, "") + fmt.Fprintln(w, " newpb := New"+FRUITS+"()") + fmt.Fprintln(w, " err = newpb.Unmarshal(reqPB.Body)") + fmt.Fprintln(w, " return newpb, reqPB, err") + fmt.Fprintln(w, "}") +} + +func httpCustomOld(w io.Writer, FRUITS string, fRUITS string, FRUIT string) { fmt.Fprintln(w, "// err handling here isn't great") fmt.Fprintln(w, "func (p *"+FRUITS+") HttpPost(baseURL string, route string) (*"+FRUITS+", *httppb.HttpRequest, error) {") fmt.Fprintln(w, " // if you ever have 'http://www.wit.com//' GO will regect the server recieving it.") |
