2023-10-02 02:45:41 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-02-16 22:36:13 +01:00
|
|
|
"embed"
|
2024-02-21 14:22:40 +01:00
|
|
|
"log"
|
2024-05-16 15:49:01 +02:00
|
|
|
"time"
|
2024-02-16 22:36:13 +01:00
|
|
|
|
2024-01-25 17:58:55 +01:00
|
|
|
"git.gnous.eu/gnouseu/plakken/internal/config"
|
|
|
|
"git.gnous.eu/gnouseu/plakken/internal/database"
|
2024-04-10 19:34:36 +02:00
|
|
|
"git.gnous.eu/gnouseu/plakken/internal/httpserver"
|
2023-10-02 02:45:41 +02:00
|
|
|
)
|
|
|
|
|
2024-02-16 22:36:13 +01:00
|
|
|
var (
|
|
|
|
//go:embed templates
|
|
|
|
templates embed.FS
|
|
|
|
//go:embed static
|
|
|
|
static embed.FS
|
|
|
|
)
|
|
|
|
|
2023-10-02 02:45:41 +02:00
|
|
|
func main() {
|
2024-01-25 17:58:55 +01:00
|
|
|
initConfig := config.GetConfig()
|
|
|
|
dbConfig := database.InitDB(initConfig.RedisAddress, initConfig.RedisUser, initConfig.RedisPassword, initConfig.RedisDB)
|
|
|
|
db := database.ConnectDB(dbConfig)
|
2024-02-21 14:22:40 +01:00
|
|
|
err := database.Ping(db)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2024-01-25 17:58:55 +01:00
|
|
|
|
2024-04-10 19:34:36 +02:00
|
|
|
serverConfig := httpserver.ServerConfig{
|
|
|
|
HTTPServer: httpserver.Config(initConfig.ListenAddress),
|
|
|
|
URLLength: initConfig.URLLength,
|
2024-01-25 17:58:55 +01:00
|
|
|
DB: db,
|
2024-02-16 22:36:13 +01:00
|
|
|
Static: static,
|
|
|
|
Templates: templates,
|
2024-05-16 15:49:01 +02:00
|
|
|
StartTime: time.Now(),
|
2023-10-05 23:18:02 +02:00
|
|
|
}
|
|
|
|
|
2024-01-25 17:58:55 +01:00
|
|
|
serverConfig.Server()
|
2023-10-02 02:45:41 +02:00
|
|
|
}
|