-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
37 lines (30 loc) · 959 Bytes
/
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
package main
import (
"discord-admin-bot/handler"
"discord-admin-bot/pkg/discord"
"discord-admin-bot/pkg/secret"
"discord-admin-bot/repo"
"github.com/gin-gonic/gin"
)
func main() {
sec := secret.GetSecret()
e := gin.Default()
e.Static("/static", "./static")
fsUserInfo := repo.NewFirestoreUserInfoRepo()
e.LoadHTMLGlob("templates/*")
oauth2 := discord.NewDiscordOAuth2Resolver()
formHandler := handler.NewInitialFormHandler(
sec.ClientID, sec.JoinForm.Callback, sec.System.Protocol, sec.System.Host,
sec.JoinForm.FormRedirectFormat, sec.DiscordSecret.MemberRoleID,
oauth2, fsUserInfo)
e.GET("/api/initial/form/debug", formHandler.RedirectDebug())
e.GET("/api/initial/form", formHandler.Redirect())
e.GET("/api/initial/form/callback", formHandler.Callback())
e.POST("/api/initial/form/submit", formHandler.AcceptSubmit())
e.GET("/health", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "ok",
})
})
e.Run(":8080")
}