much better standard autogen code
This commit is contained in:
parent
96cd7ffb2d
commit
da3244d265
|
@ -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.")
|
||||
|
|
Loading…
Reference in New Issue