mirror of
https://codeberg.org/video-prize-ranch/rimgo.git
synced 2025-12-13 11:45:18 +00:00
Remove viper and file configuration
This commit is contained in:
24
main.go
24
main.go
@@ -1,41 +1,25 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"codeberg.org/video-prize-ranch/rimgo/pages"
|
||||
"codeberg.org/video-prize-ranch/rimgo/static"
|
||||
"codeberg.org/video-prize-ranch/rimgo/utils"
|
||||
"codeberg.org/video-prize-ranch/rimgo/views"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/fiber/v2/middleware/filesystem"
|
||||
"github.com/gofiber/fiber/v2/middleware/recover"
|
||||
"github.com/gofiber/template/handlebars"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func main() {
|
||||
viper.SetConfigName("config")
|
||||
viper.SetConfigType("yml")
|
||||
viper.AddConfigPath("/etc/rimgu/")
|
||||
viper.AddConfigPath("$HOME/.config/rimgu")
|
||||
viper.AddConfigPath(".")
|
||||
viper.AutomaticEnv()
|
||||
|
||||
viper.SetDefault("RIMGU_PORT", "3000")
|
||||
viper.SetDefault("RIMGU_HOST", "localhost")
|
||||
viper.SetDefault("RIMGU_ADDRESS", "0.0.0.0")
|
||||
viper.SetDefault("RIMGU_IMGUR_CLIENT_ID", "546c25a59c58ad7")
|
||||
|
||||
err := viper.ReadInConfig()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
utils.LoadConfig()
|
||||
|
||||
engine := handlebars.NewFileSystem(http.FS(views.GetFiles()), ".hbs")
|
||||
app := fiber.New(fiber.Config{
|
||||
Views: engine,
|
||||
Prefork: viper.GetBool("FIBER_PREFORK"),
|
||||
Prefork: utils.Config["fiberPrefork"].(bool),
|
||||
UnescapePath: true,
|
||||
StreamRequestBody: true,
|
||||
})
|
||||
@@ -68,5 +52,5 @@ func main() {
|
||||
app.Get("/user/:userID/avatar", pages.HandleUserAvatar)
|
||||
app.Get("/gallery/:galleryID", pages.HandleGallery)
|
||||
|
||||
app.Listen(":" + viper.GetString("RIMGU_PORT"))
|
||||
app.Listen(":" + utils.Config["port"].(string))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user