added array to params
This commit is contained in:
+4
-23
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user