mirror of
https://github.com/WiiLink24/wfc-server.git
synced 2026-05-06 05:26:33 -05:00
42 lines
670 B
Go
42 lines
670 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
"wwfc/common"
|
|
"wwfc/database"
|
|
)
|
|
|
|
var (
|
|
db database.Connection
|
|
|
|
apiSecret string
|
|
)
|
|
|
|
func StartServer(reload bool) {
|
|
// Get config
|
|
config := common.GetConfig()
|
|
|
|
apiSecret = config.APISecret
|
|
|
|
// Start SQL
|
|
db = database.Start(config)
|
|
|
|
db.RegisterEvents(config, []string{
|
|
"profile_kicked",
|
|
"profile_banned",
|
|
"profile_unbanned",
|
|
})
|
|
}
|
|
|
|
func Shutdown() {
|
|
db.Close()
|
|
}
|
|
|
|
func RegisterHandlers(mux *http.ServeMux) {
|
|
mux.HandleFunc("/api/groups", HandleGroups)
|
|
mux.HandleFunc("/api/stats", HandleStats)
|
|
mux.HandleFunc("/api/ban", HandleBan)
|
|
mux.HandleFunc("/api/unban", HandleUnban)
|
|
mux.HandleFunc("/api/kick", HandleKick)
|
|
}
|