diff --git a/backend/GO_API/APIFile/APIFile.exe b/backend/GO_API/APIFile/APIFile.exe deleted file mode 100644 index a3e1ada..0000000 Binary files a/backend/GO_API/APIFile/APIFile.exe and /dev/null differ diff --git a/backend/GO_API/APIFile/APIFile.go b/backend/GO_API/APIFile/APIFile.go deleted file mode 100644 index 74719b9..0000000 --- a/backend/GO_API/APIFile/APIFile.go +++ /dev/null @@ -1,37 +0,0 @@ -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) -} \ No newline at end of file diff --git a/backend/GO_API/GO_API.exe b/backend/GO_API/GO_API.exe new file mode 100644 index 0000000..661aa3d Binary files /dev/null and b/backend/GO_API/GO_API.exe differ diff --git a/backend/GO_API/server.go b/backend/GO_API/server.go new file mode 100644 index 0000000..57d303f --- /dev/null +++ b/backend/GO_API/server.go @@ -0,0 +1,40 @@ +package main + +import ( + "net/http" + + "github.com/labstack/echo" + "github.com/labstack/echo/middleware" +) + +type Task struct { + Title string + Description string +} + +func main() { + e := echo.New() + + // Middleware + e.Use(middleware.Logger()) + e.Use(middleware.Recover()) + + //CORS + e.Use(middleware.CORSWithConfig(middleware.CORSConfig{ + AllowOrigins: []string{"*"}, + AllowMethods: []string{echo.GET, echo.HEAD, echo.PUT, echo.PATCH, echo.POST, echo.DELETE}, + })) + + task := Task{ + "First task", + "This is my first task in GO language", + } + + // Route => handler + e.GET("/", func(c echo.Context) error { + return c.String(http.StatusOK, "Title: " + task.Title + "\nDescription: " + task.Description) + }) + + // Server + e.Start(":1323") +} \ No newline at end of file