mirror of https://github.com/tad17/tad
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
600 B
Go
30 lines
600 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/jmoiron/sqlx"
|
|
"github.com/tad17/tad/fiber"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
func testRouter(db *sqlx.DB, query string) string {
|
|
//fmt.Printf("query: %s\n", query)
|
|
var urls []string
|
|
cmd := "select newurl from filemeta limit 5"
|
|
if err := db.Select(&urls, cmd); err != nil {
|
|
fmt.Errorf("ошибка выполнения: %s", cmd)
|
|
os.Exit(0)
|
|
}
|
|
s := strings.Join(urls, " ")
|
|
return s
|
|
}
|
|
|
|
func main() {
|
|
db := fiber.OpenDB("sea")
|
|
app := fiber.NewApp("test-app", db)
|
|
app.JSONRouter("/test", testRouter)
|
|
app.Start(4444)
|
|
fmt.Printf("init app fiber: %v\n", app)
|
|
}
|