Refactor server to go-sqlite and ginext [WIP]
This commit is contained in:
@@ -3,8 +3,11 @@ package main
|
||||
import (
|
||||
"blackforestbytes.com/simplecloudnotifier/db/schema"
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"github.com/glebarez/go-sqlite"
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/exerr"
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/langext"
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/sq"
|
||||
"time"
|
||||
)
|
||||
@@ -15,7 +18,9 @@ func main() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
sqlite3.Version() // ensure slite3 loaded
|
||||
if !langext.InArray("sqlite3", sql.Drivers()) {
|
||||
sqlite.RegisterAsSQLITE3()
|
||||
}
|
||||
|
||||
fmt.Println()
|
||||
|
||||
|
@@ -135,7 +135,7 @@ func main() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
dbold := sq.NewDB(_dbold)
|
||||
dbold := sq.NewDB(_dbold, sq.DBOptions{})
|
||||
|
||||
rowsUser, err := dbold.Query(ctx, "SELECT * FROM users", sq.PP{})
|
||||
if err != nil {
|
||||
|
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/rs/zerolog/log"
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/ginext"
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/langext"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -33,10 +34,11 @@ func main() {
|
||||
}
|
||||
|
||||
ginengine := ginext.NewEngine(ginext.Options{
|
||||
AllowCors: &conf.Cors,
|
||||
GinDebug: &conf.GinDebug,
|
||||
BufferBody: langext.PTrue,
|
||||
Timeout: &conf.RequestTimeout,
|
||||
AllowCors: &conf.Cors,
|
||||
GinDebug: &conf.GinDebug,
|
||||
BufferBody: langext.PTrue,
|
||||
Timeout: langext.Ptr(time.Duration(int64(conf.RequestTimeout) * int64(conf.RequestMaxRetry))),
|
||||
BuildRequestBindError: logic.BuildGinRequestError,
|
||||
})
|
||||
|
||||
router := api.NewRouter(app)
|
||||
|
Reference in New Issue
Block a user