forked from tkaburagi/various-workloads-on-nomad
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfront-api-msa.go
36 lines (29 loc) · 822 Bytes
/
front-api-msa.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"net/http"
"github.com/labstack/echo"
b64 "encoding/base64"
"bytes"
"fmt"
)
func main() {
e := echo.New()
e.GET("/animal/:name", invokeFunc)
e.Logger.Fatal(e.Start(":8888"))
}
func invokeFunc(c echo.Context) error{
animal := c.Param("name")
fmt.Println(animal)
animal64 := b64.StdEncoding.EncodeToString([]byte(animal))
var jsonStr = []byte(`{"Payload":"` + animal64 + `"}`)
url := "http://172.28.128.11:4646/v1/job/04-parameterized-toUpper/dispatch?namespace=msa"
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
return err
}