Changes related mainly to status codes

This commit is contained in:
emirbarucija
2018-05-23 18:56:12 +02:00
parent 20ab74f392
commit 9ac172bcb0
8 changed files with 14 additions and 14 deletions

View File

@@ -1,2 +0,0 @@
# Serverless directories
.serverless

View File

@@ -37,15 +37,16 @@ func main() {
func Handler() (events.APIGatewayProxyResponse, error) { func Handler() (events.APIGatewayProxyResponse, error) {
// Getting JSON as []byte // Getting JSON as []byte
b, err := convertTasksToJSON() b, err := convertTasksToJSON()
if err != nil { status := 200
fmt.Println("error:", err) if err != nil {
status = 500
} }
return events.APIGatewayProxyResponse { return events.APIGatewayProxyResponse {
Body: string(b[:]), Body: string(b[:]),
StatusCode: 200, StatusCode: status,
}, nil }, err
} }
func convertTasksToJSON() ([]byte, error) { func convertTasksToJSON() ([]byte, error) {

View File

@@ -37,15 +37,16 @@ func main() {
func Handler() (events.APIGatewayProxyResponse, error) { func Handler() (events.APIGatewayProxyResponse, error) {
// Getting JSON as []byte // Getting JSON as []byte
b, err := convertTasksToJSON() b, err := convertTasksToJSON()
if err != nil { status := 200
fmt.Println("error:", err) if err != nil {
status = 500
} }
return events.APIGatewayProxyResponse { return events.APIGatewayProxyResponse {
Body: string(b[:]), Body: string(b[:]),
StatusCode: 200, StatusCode: status,
}, nil }, err
} }
func convertTasksToJSON() ([]byte, error) { func convertTasksToJSON() ([]byte, error) {

View File

@@ -15,5 +15,5 @@ functions:
handler: bin/Task_API handler: bin/Task_API
events: events:
- http: - http:
path: /tasks path: tasks
method: get method: GET