-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.go
41 lines (36 loc) · 1.14 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
40
41
package main
import (
"github.com/CloudNativeGame/aigc-gateway/pkg/routers"
"github.com/CloudNativeGame/aigc-gateway/pkg/utils"
"github.com/gin-contrib/sessions"
"github.com/gin-contrib/sessions/memstore"
"github.com/gin-contrib/static"
"github.com/gin-gonic/gin"
"github.com/logto-io/go/client"
"os"
)
func main() {
router := gin.Default()
// load templates
router.Delims("{[{", "}]}")
router.LoadHTMLGlob("aigc-dashboard/dist/*.html")
router.Use(static.Serve("/assets", static.LocalFile("aigc-dashboard/dist/assets", true)))
endpoint := os.Getenv("Endpoint")
logtoConfig := &client.LogtoConfig{
Endpoint: endpoint,
AppId: os.Getenv("App_Id"),
AppSecret: os.Getenv("App_Secret"),
Scopes: []string{"email", "custom_data"},
}
// We use memory-based session in this example
store := memstore.NewStore([]byte("your session secret"))
store.Options(sessions.Options{
Domain: utils.GetDomainFromEndpoint(endpoint),
Path: "/",
MaxAge: 604800,
})
router.Use(sessions.Sessions("logto-session", store))
routers.RegisterSignRouters(router, logtoConfig)
routers.RegisterResourceRouters(router, logtoConfig)
router.Run(":8090")
}