Modified some files
This commit is contained in:
@@ -7,6 +7,8 @@ import (
|
||||
|
||||
"github.com/labstack/echo"
|
||||
"github.com/labstack/echo/middleware"
|
||||
"github.com/aws/aws-lambda-go/events"
|
||||
"github.com/aws/aws-lambda-go/lambda"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
@@ -23,6 +25,10 @@ type Task struct {
|
||||
}
|
||||
|
||||
func main() {
|
||||
lambda.Start(Handler)
|
||||
}
|
||||
|
||||
func Handler() (events.APIGatewayProxyResponse, error) {
|
||||
e := echo.New()
|
||||
|
||||
// Middleware
|
||||
@@ -36,7 +42,7 @@ func main() {
|
||||
}))
|
||||
|
||||
// Getting JSON as []byte
|
||||
b, err := Handler()
|
||||
b, err := convertTasksToJSON()
|
||||
if err != nil {
|
||||
fmt.Println("error:", err)
|
||||
}
|
||||
@@ -48,17 +54,14 @@ func main() {
|
||||
|
||||
// Server
|
||||
e.Start(":1500")
|
||||
|
||||
return events.APIGatewayProxyResponse{
|
||||
Body: b,
|
||||
StatusCode: 200,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (u User) String() string {
|
||||
return fmt.Sprintf("Username: %v\nFirst name: %v\nLast name: %v", u.Username, u.FirstName, u.LastName)
|
||||
}
|
||||
|
||||
func (t Task) String() string {
|
||||
return fmt.Sprintf("Title: %v\nDescription: %v\nUser: %v\nDate: %v", t.Title, t.Description, t.UserOfTask, t.Date)
|
||||
}
|
||||
|
||||
func Handler() ([]byte, error) {
|
||||
func convertTasksToJSON() ([]byte, error) {
|
||||
user := User {
|
||||
Username: "emirbarucija",
|
||||
FirstName: "Emir",
|
||||
@@ -84,4 +87,12 @@ func Handler() ([]byte, error) {
|
||||
b, err := json.Marshal(tasks)
|
||||
|
||||
return b, err
|
||||
}
|
||||
|
||||
func (u User) String() string {
|
||||
return fmt.Sprintf("Username: %v\nFirst name: %v\nLast name: %v", u.Username, u.FirstName, u.LastName)
|
||||
}
|
||||
|
||||
func (t Task) String() string {
|
||||
return fmt.Sprintf("Title: %v\nDescription: %v\nUser: %v\nDate: %v", t.Title, t.Description, t.UserOfTask, t.Date)
|
||||
}
|
||||
Reference in New Issue
Block a user