Fix route_add{,_test}.go to use an io.Writer for saving the response

Also add a TODO regarding untested response payload.

Co-authored-by: Héctor Hurtado <hector.hurtado@bbva.com>
This commit is contained in:
pancho horrillo
2019-10-04 06:28:17 +02:00
parent 219710bb76
commit b9bf78abf4
2 changed files with 8 additions and 3 deletions
+4 -2
View File
@@ -3,16 +3,18 @@ package client
import (
"bytes"
"encoding/json"
"io"
"github.com/BBVA/kapow/internal/http"
)
// AddRoute will add a new route in kapow
func AddRoute(host, path, method, entrypoint, command string) error {
func AddRoute(host, path, method, entrypoint, command string, w io.Writer) error {
url := host + "/routes"
body, _ := json.Marshal(map[string]string{
"method": method,
"url_pattern": path,
"entrypoint": entrypoint,
"command": command})
return http.Put(url, "application/json", bytes.NewReader(body), nil)
return http.Put(url, "application/json", bytes.NewReader(body), w)
}