40 lines
735 B
Go
40 lines
735 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"github.com/labstack/echo"
|
||
|
"github.com/labstack/echo/middleware"
|
||
|
"html/template"
|
||
|
"github.com/labstack/gommon/log"
|
||
|
)
|
||
|
|
||
|
func main(){
|
||
|
//Config
|
||
|
SiteConf := initConfig()
|
||
|
|
||
|
//Echo init
|
||
|
e := echo.New()
|
||
|
|
||
|
//Logger
|
||
|
e.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
|
||
|
Format: "${time_rfc3339}: ${remote_ip} ${method} ${status} ${uri} - ${user_agent}\n",
|
||
|
}))
|
||
|
|
||
|
//Static ontent
|
||
|
e.Static("/assets", "assets")
|
||
|
|
||
|
//Routes
|
||
|
e.GET("/", showList)
|
||
|
e.GET("/list", getList)
|
||
|
e.GET("/admin", adminHandler)
|
||
|
|
||
|
//Template
|
||
|
t := &Template{
|
||
|
templates: template.Must(template.ParseGlob("tpl/*.html")),
|
||
|
}
|
||
|
e.Renderer = t
|
||
|
|
||
|
//Start the server
|
||
|
e.Logger.SetLevel(log.ERROR)
|
||
|
e.Logger.Debug(e.Start(SiteConf.Interface))
|
||
|
}
|