-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
39 lines (32 loc) · 1 KB
/
main.go
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
package main
import (
"context"
"encoding/json"
"shrampybot/controller/admin"
"shrampybot/controller/auth"
"shrampybot/controller/event"
"shrampybot/controller/gsg"
"shrampybot/controller/public"
"shrampybot/router"
"github.com/aws/aws-lambda-go/lambda"
)
func Main(ctx context.Context, ev map[string]any) (router.AWSResponse, error) {
var evnt router.Event
evBytes, _ := json.Marshal(ev)
// Uncomment if there's a need to log headers
// log.Println(string(evBytes))
json.Unmarshal(evBytes, &evnt)
router := router.NewRouter(&ctx, &evnt)
router.AddRoute("admin", admin.AdminController, true)
router.AddRoute("gsg", gsg.GSGController, true)
// These don't necessarily lack auth, but they handle auth
// themselves in various ways
router.AddRoute("auth", auth.AuthController, false)
router.AddRoute("event", event.EventController, false)
router.AddRoute("public", public.PublicController, false)
routeResp := router.Route()
return routeResp.FormatAWS(), nil
}
func main() {
lambda.Start(Main)
}