added array to params

This commit is contained in:
2020-12-12 09:21:12 -03:00
parent 65facd7a02
commit 3d72f44205
12 changed files with 138 additions and 118 deletions
+4 -23
View File
@@ -4,7 +4,6 @@ import (
"bytes"
"encoding/json"
"net/http"
"time"
)
var Basepath string = ""
@@ -38,31 +37,13 @@ func invoke(m string, path string, bodyo interface{}) (*json.Decoder, error) {
return ret, nil
}
func Some() (*struct{}, error) {
dec, err := invoke("a", "/c/d", struct{}{})
ret := &struct{}{}
dec.Decode(ret)
return ret, err
type AStr struct {
A string `json:"a"`
}
type ARequestStruct struct {
A string `json:"a"`
B int64 `json:"b"`
C time.Time `json:"c"`
D string `json:"d"`
}
type AResponseStruct struct {
A string `json:"a"`
B int64 `json:"b"`
C time.Time `json:"c"`
D string `json:"d"`
}
func SomeAPI(req *ARequestStruct) (res *AResponseStruct, err error) {
func SomeAPI2(req *AStr) (res []*AStr, err error) {
dec, err := invoke("POST", "/someapi", req)
ret := &AResponseStruct{}
ret := []*AStr{}
err = dec.Decode(ret)
if err != nil {
return nil, err