Made GO API
This commit is contained in:
BIN
backend/GO_API/APIFile/APIFile.exe
Normal file
BIN
backend/GO_API/APIFile/APIFile.exe
Normal file
Binary file not shown.
37
backend/GO_API/APIFile/APIFile.go
Normal file
37
backend/GO_API/APIFile/APIFile.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user