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.
27 lines
548 B
Go
27 lines
548 B
Go
1 year ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"github.com/gofiber/fiber/v2"
|
||
|
"github.com/jmoiron/sqlx"
|
||
|
)
|
||
|
|
||
|
func initRouter(app *fiber.App, db *sqlx.DB) {
|
||
|
app.Static("/", "app/dist")
|
||
|
app.Static("/assets", "app/dist/assets", fiber.Static{
|
||
|
Compress: true,
|
||
|
})
|
||
|
app.Static("/fonts", "app/dist/fonts", fiber.Static{
|
||
|
Compress: true,
|
||
|
})
|
||
|
|
||
|
app.Get("/albums", albums(db))
|
||
|
}
|
||
|
|
||
|
func albums(db *sqlx.DB) fiber.Handler {
|
||
|
return func(c *fiber.Ctx) error {
|
||
|
albums := getAlbums(db)
|
||
|
// fmt.Printf("- получено albums: (%d)\n", len(albums))
|
||
|
return c.JSON(albums)
|
||
|
}
|
||
|
}
|