-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
50 lines (42 loc) · 1.28 KB
/
main.go
File metadata and controls
50 lines (42 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"github.com/Toskosz/serverless-tradelog/handlers"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
)
func handler(req events.APIGatewayProxyRequest) (
*events.APIGatewayProxyResponse, error) {
h := handlers.NewHandler()
if req.HTTPMethod == "GET" && req.Path == "/healthcheck" {
return h.HealthCheck(req.Path)
}
// AUTH ENDPOINTS
if req.HTTPMethod == "POST" && req.Path == "/register" {
return h.Register(req)
} else if req.HTTPMethod == "POST" && req.Path == "/login" {
return h.Login(req)
} else if req.HTTPMethod == "POST" && req.Path == "/logout" {
return h.Logout(req)
// LOG ENDPOINTS
} else if req.HTTPMethod == "GET" && req.Path == "/my/logs" {
if _, ok := req.QueryStringParameters["log-abertura"]; ok {
return h.GetLog(req)
} else {
return h.GetMyLogs(req)
}
} else if req.HTTPMethod == "POST" && req.Path == "/my/logs" {
return h.CreateLog(req)
} else if req.HTTPMethod == "PUT" && req.Path == "/my/logs" {
return h.UpdateLog(req)
} else if req.HTTPMethod == "DELETE" && req.Path == "/my/logs" {
return h.DeleteLog(req)
} else {
return h.UnhandledMethod()
}
}
func main() {
lambda.Start(handler)
}
// else if req.HTTPMethod == "GET" && req.Path == "/my/logs" {
// return h.GetMyLogs(req)
//}