-
-
Notifications
You must be signed in to change notification settings - Fork 456
/
main.go
44 lines (38 loc) · 880 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"app/template"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/filesystem"
"github.com/gofiber/fiber/v2/middleware/logger"
)
const (
appName = "Sveltekit Embed App"
apiVersion = "v1"
port = ":3000"
)
func main() {
// Create new Fiber Instance
app := fiber.New(fiber.Config{
AppName: appName,
})
defer app.Shutdown()
// Middleware
app.Use(cors.New(cors.Config{
AllowOrigins: "*",
AllowHeaders: "*",
}))
app.Use(logger.New(logger.Config{
Format: "[${ip}]:${port} ${status} - ${method} ${path}\n",
}))
// Serve static files
app.All("/*", filesystem.New(filesystem.Config{
Root: template.Dist(),
NotFoundFile: "index.html",
Index: "index.html",
}))
// Start the server
if err := app.Listen(port); err != nil {
panic(err)
}
}