wfc-server/api/main.go
Palapeli c002bb81a6
Some checks are pending
Build CI / build (push) Waiting to run
golangci-lint / lint (push) Waiting to run
Rework HTTP request handling entirely
2026-04-06 11:35:02 -04:00

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)
}