37 lines
728 B
Go
37 lines
728 B
Go
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)
|
|
} |