Changeset 61 in code for trunk/cmd


Ignore:
Timestamp:
Jan 21, 2024, 2:42:45 AM (17 months ago)
Author:
yakumo.izuru
Message:

マニュアルページを更新したり、PixivFE からインスピレーションを得たり...

Signed-off-by: Izuru Yakumo <yakumo.izuru@…>

Location:
trunk/cmd/mai
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/cmd/mai/main.go

    r60 r61  
    55        "net/http"
    66        "net/url"
     7        "os"
    78        "time"
    89        "runtime"
     
    1011        "marisa.chaotic.ninja/mai/engines"
    1112        "github.com/gofiber/fiber/v2"
     13        "github.com/gofiber/fiber/v2/middleware/logger"
     14        "github.com/gofiber/fiber/v2/middleware/limiter"
    1215        "github.com/gofiber/template/html/v2"
    1316)
     
    1720var conf struct {
    1821        listen string
     22        redisuri string
    1923        staticpath string
    2024        tmplpath string
     
    3438        engine := html.New(conf.tmplpath, ".html")
    3539        engine.AddFunc("inc", func(i int) int { return i + 1 })
    36 
    37         app := fiber.New(fiber.Config{
    38                 Views: engine,
    39         })
     40        storage := redis.New(
     41                redis.Config{
     42                        URL: conf.redisuri,
     43                },
     44        )
     45
     46        app := fiber.New(
     47                fiber.Config{
     48                        AppName: "Mai",
     49                        DisableStartupMessage: true,
     50                        Views: engine,
     51        })
     52
     53        app.Use(logger.New(
     54                logger.Config{
     55                        Format: "==> ${ip}:${port} ${status} - ${method} ${path}\n",
     56                        DisableColors: true,
     57                        Output: os.Stdout,
     58                },
     59        ))
     60
     61        app.Use(limiter.New())
    4062
    4163        app.All("/", func(c *fiber.Ctx) error {
  • trunk/cmd/mai/readconf.go

    r56 r61  
    1313
    1414        conf.listen = cfg.Section("mai").Key("listen").String()
    15         conf.staticpath = cfg.Section("mai").Key("rootdir").String()                                           
    16         conf.tmplpath = cfg.Section("mai").Key("tmplpath").String()
     15        conf.staticpath = cfg.Section("mai").Key("static").String()
     16        conf.tmplpath = cfg.Section("mai").Key("templates").String()
    1717
    1818        return nil
Note: See TracChangeset for help on using the changeset viewer.