35 lines
1.1 KiB
Go
Executable file
35 lines
1.1 KiB
Go
Executable file
package main
|
|
|
|
import (
|
|
api "example.com/api"
|
|
authdiscord "example.com/auth/discord"
|
|
database "example.com/database"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func main() {
|
|
api.GlobalDatabase = database.InitializeDatabase()
|
|
api.GlobalConfig.ParseConfig("../config.toml")
|
|
api.GlobalOAuth = authdiscord.CreateDiscordOAuthConfig(api.GlobalConfig)
|
|
router := gin.Default()
|
|
// Authentication Workflow
|
|
router.GET("/auth/callback", api.AuthCallback)
|
|
router.GET("/auth/login", api.AuthLoginRedirect)
|
|
router.GET("/auth/logout", api.AuthLogoutRedirect)
|
|
// Create
|
|
router.POST("/user/update", api.CreateOrUpdateUser)
|
|
router.POST("/group", api.CreateGroup)
|
|
router.POST("/function", api.CreateFunction)
|
|
router.POST("/function-tag", api.CreateFunctionTag)
|
|
// Update
|
|
router.PUT("/function", api.UpdateFunction)
|
|
// Read
|
|
router.GET("/user/info", api.GetDiscordUser)
|
|
router.GET("/user/authorized", api.GetUserLoggedIn)
|
|
router.GET("/:object", api.GetObjects)
|
|
router.GET("/all/:object", api.GetAllObjects)
|
|
// Delete
|
|
router.DELETE("/function", api.DeleteFunction)
|
|
router.Run(":31337")
|
|
}
|