From 990ac72c527651a9859db770a38e710a3306ba3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paulo=20Sima=CC=83o?= Date: Sat, 20 Nov 2021 09:21:22 -0300 Subject: [PATCH] add apiproxy --- api/apiproxy/lib.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 api/apiproxy/lib.go diff --git a/api/apiproxy/lib.go b/api/apiproxy/lib.go new file mode 100644 index 0000000..cba4701 --- /dev/null +++ b/api/apiproxy/lib.go @@ -0,0 +1,34 @@ +package apiproxy + +import "go.digitalcircle.com.br/open/replaycli-go/api" + +type APIProxyRequest struct { + Name string `json:"name,omitempty"` + Method string `json:"method,omitempty"` + Url string `json:"url,omitempty"` + Header map[string]string `json:"header,omitempty"` + Body []byte `json:"body,omitempty"` + Readonly bool `json:"readonly"` +} + +type APIProxyResponse struct { + Status string `json:"status"` + StatusCode int `json:"status_code"` + Header map[string]string `json:"header,omitempty"` + Body []byte `json:"body,omitempty"` +} + +type Cli struct { + *api.ApiCli +} + +func (c *Cli) Do(req *APIProxyRequest) (*APIProxyResponse, error) { + res := &APIProxyResponse{} + err := c.HttpCli().JsonPost("/ipc/apiproxy/do", req, res) + return res, err +} + +func NewCli() *Cli { + ret := &Cli{ApiCli: api.NewApiCli()} + return ret +}