-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
41 lines (34 loc) · 909 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
38
39
40
41
package main
import (
"log"
"github.com/Darklabel91/API_Names/database"
"github.com/Darklabel91/API_Names/models"
"github.com/Darklabel91/API_Names/routes"
)
func init() {
// Connect to the database.
db, err := database.ConnectDB()
if err != nil {
log.Fatalf("Error connecting to the database: %v", db.Error)
}
models.DB = db
// Create the root user.
if err := models.CreateRoot(); err != nil {
log.Fatalf("Error creating root user: %v", err)
}
// Get the list of trusted IPs from the database.
trustedIPs, err := models.TrustedIPs()
if err != nil {
log.Fatalf("Error getting trusted IPs: %v", err)
}
// Store the list of trusted IPs in the models package.
models.IPs = trustedIPs
}
func main() {
// Handle incoming HTTP requests.
log.Println("- Listening and serving...")
err := routes.HandleRequests()
if err != nil {
log.Fatalf("Error handling requests: %v", err)
}
}