-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
53 lines (44 loc) · 1.18 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/logger"
"yohanestatus/minecraft"
"yohanestatus/ragnarok"
"yohanestatus/database"
"log"
)
func main() {
app := fiber.New()
// Menghubungkan ke database
err := database.ConnectDB()
if err != nil {
log.Fatalf("Gagal terhubung ke database: %v", err)
}
defer database.CloseDB()
// Menambahkan middleware logger
app.Use(logger.New(logger.Config{
Format: "${time} - ${ip} - ${url} - ${status} - ${method} - ${latency} - ${ua}\n",
TimeFormat: "2006-01-02 15:04:05",
TimeZone: "Asia/Jakarta",
}))
app.Get("/status", handleStatus)
// Menambahkan rute untuk redirect ke datenshi.pw
app.Get("/", func(c *fiber.Ctx) error {
return c.Redirect("https://datenshi.pw", 301)
})
app.Listen(":3000")
}
func handleStatus(c *fiber.Ctx) error {
games := c.Query("games")
switch games {
case "0":
return minecraft.HandleMCStatus(c)
case "1":
return ragnarok.HandleRagnarokStatus(c)
case "2":
// Implementasi untuk game 2 bisa ditambahkan di sini
return c.SendString("Implementasi untuk game 2 belum tersedia")
default:
return c.Status(400).SendString("Nilai games tidak valid")
}
}