add 数据库 Web框架 初步 支持

This commit is contained in:
2024-10-28 18:59:34 +08:00
parent 221f216c3d
commit 4ceb33fbf2
14 changed files with 152 additions and 2 deletions

View File

@@ -21,6 +21,7 @@ func Load() {
File = viper.GetString("File")
DB.Path = viper.GetString("DB.Path")
//DB.Port = viper.GetString("DB.Port")
DB.Type = viper.GetString("DB.Type")
err := check()
if err != nil {
@@ -42,5 +43,6 @@ func debugprint() {
fmt.Printf("ListenPort=%v\n", ListenPort)
fmt.Printf("File=%v\n", File)
fmt.Printf("database path : %s\n", DB.Path)
fmt.Printf("database type:%s\n", DB.Type)
}

12
config/middleware.go Normal file
View File

@@ -0,0 +1,12 @@
package config
import (
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
func Middleware(app *echo.Echo) {
//here are middlewares we use
app.Use(middleware.Logger())
app.Use(middleware.Recover())
}

View File

@@ -13,4 +13,5 @@ type database struct {
//Password string
// enable if you want use an instance other than SQLite
Type string
}

10
config/route.go Normal file
View File

@@ -0,0 +1,10 @@
package config
import (
"github.com/labstack/echo/v4"
)
func Route(app *echo.Echo) {
// here is the route for our site
app.File("/", "FrontEnd/index.html")
}