Files
kapow/internal/client/route_add.go
pancho horrillo 81cbea4ff8 Fix method used in client.AddRoute()
Co-authored-by: César Gallego <gallego.cesar@gmail.com>
2019-10-17 16:58:38 +02:00

21 lines
469 B
Go

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, w io.Writer) error {
url := host + "/routes"
body, _ := json.Marshal(map[string]string{
"method": method,
"url_pattern": path,
"entrypoint": entrypoint,
"command": command})
return http.Post(url, "application/json", bytes.NewReader(body), w)
}