マニュアルページを更新したり、PixivFE からインスピレーションを得たり...
Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja> git-svn-id: file:///srv/svn/repo/mai/trunk@61 e410bdd4-646f-c54f-a7ce-fffcc4f439ae
This commit is contained in:
@@ -4,11 +4,14 @@ import (
|
||||
"bytes"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"time"
|
||||
"runtime"
|
||||
|
||||
"marisa.chaotic.ninja/mai/engines"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/fiber/v2/middleware/logger"
|
||||
"github.com/gofiber/fiber/v2/middleware/limiter"
|
||||
"github.com/gofiber/template/html/v2"
|
||||
)
|
||||
var (
|
||||
@@ -16,6 +19,7 @@ var (
|
||||
)
|
||||
var conf struct {
|
||||
listen string
|
||||
redisuri string
|
||||
staticpath string
|
||||
tmplpath string
|
||||
}
|
||||
@@ -33,11 +37,29 @@ func main() {
|
||||
|
||||
engine := html.New(conf.tmplpath, ".html")
|
||||
engine.AddFunc("inc", func(i int) int { return i + 1 })
|
||||
storage := redis.New(
|
||||
redis.Config{
|
||||
URL: conf.redisuri,
|
||||
},
|
||||
)
|
||||
|
||||
app := fiber.New(fiber.Config{
|
||||
Views: engine,
|
||||
app := fiber.New(
|
||||
fiber.Config{
|
||||
AppName: "Mai",
|
||||
DisableStartupMessage: true,
|
||||
Views: engine,
|
||||
})
|
||||
|
||||
app.Use(logger.New(
|
||||
logger.Config{
|
||||
Format: "==> ${ip}:${port} ${status} - ${method} ${path}\n",
|
||||
DisableColors: true,
|
||||
Output: os.Stdout,
|
||||
},
|
||||
))
|
||||
|
||||
app.Use(limiter.New())
|
||||
|
||||
app.All("/", func(c *fiber.Ctx) error {
|
||||
engine := c.Cookies("engine")
|
||||
if c.Query("engine") != "" {
|
||||
|
||||
@@ -12,8 +12,8 @@ func readConf(file string) error {
|
||||
}
|
||||
|
||||
conf.listen = cfg.Section("mai").Key("listen").String()
|
||||
conf.staticpath = cfg.Section("mai").Key("rootdir").String()
|
||||
conf.tmplpath = cfg.Section("mai").Key("tmplpath").String()
|
||||
conf.staticpath = cfg.Section("mai").Key("static").String()
|
||||
conf.tmplpath = cfg.Section("mai").Key("templates").String()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user