cpularp-manager-api/src/gin-cpularp.go

37 lines
1.2 KiB
Go
Raw Normal View History

2025-04-24 13:58:05 -05:00
package main
import (
api "example.com/api"
authdiscord "example.com/auth/discord"
2025-04-29 00:42:57 -05:00
database "example.com/database"
2025-04-24 13:58:05 -05:00
"github.com/gin-gonic/gin"
)
func main() {
2025-04-29 00:42:57 -05:00
api.GlobalDatabase = database.InitializeDatabase()
api.GlobalConfig.ParseConfig("../config.toml")
2025-04-24 13:58:05 -05:00
api.GlobalOAuth = authdiscord.CreateDiscordOAuthConfig(api.GlobalConfig)
app := gin.Default()
2025-04-24 17:08:09 -05:00
// Authentication Workflow
2025-04-24 13:58:05 -05:00
app.GET("/auth/callback", api.AuthCallback)
2025-04-24 17:08:09 -05:00
app.GET("/auth/login", api.AuthLoginRedirect)
app.GET("/auth/logout", api.AuthLogoutRedirect)
// Create & Update
app.POST("/post/user/update", api.CreateOrUpdateUser)
2025-04-29 00:42:57 -05:00
app.POST("/post/group", api.CreateGroup)
app.POST("/post/function", api.CreateFunction)
app.POST("/post/function-tag", api.CreateFunctionTag)
2025-04-24 17:08:09 -05:00
// Read
2025-04-29 00:42:57 -05:00
app.GET("/get/user/info", api.GetDiscordUser)
app.GET("/get/user/authorized", api.GetUserLoggedIn)
app.GET("/get/groups", api.GetGroups)
app.GET("/get/all/groups", api.GetAllGroups)
app.GET("/get/functions", api.GetFunctions)
app.GET("/get/all/functions", api.GetAllFunctions)
app.GET("/get/function-tags", api.GetFunctionTags)
app.GET("/get/all/function-tags", api.GetAllFunctionTags)
2025-04-24 17:08:09 -05:00
// Delete
2025-04-24 13:58:05 -05:00
app.Run(":31337")
}