Made GO API

This commit is contained in:
emirbarucija
2018-05-09 15:56:57 +02:00
parent 96c4d09429
commit 205c70de23
2 changed files with 37 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,37 @@
package main
import (
"fmt"
"encoding/json"
"os"
)
type Response struct {
StatusCode int `json:"statusCode"`
Headers map[string]string `json:"headers"`
Body string `json:"body"`
}
func Handler() ([]byte, error) {
m := []Response{
Response{
StatusCode: 200,
Headers: map[string]string {"Content-Type": "application/json"},
Body: "This is the first task",
},
Response{
StatusCode: 200,
Headers: map[string]string {"Content-Type": "application/json"},
Body: "This is the second task",
}}
b, err := json.Marshal(m)
return b, err
}
func main() {
b, err := Handler()
if err != nil {
fmt.Println("error:", err)
}
os.Stdout.Write(b)
}