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")
}