-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
105 lines (99 loc) · 2.02 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package main
import (
"archive/tar"
"log"
"net/http"
"os"
"github.com/bketelsen/fleekgen/bling"
"github.com/bketelsen/fleekgen/devbox"
"github.com/gofiber/fiber/v2"
)
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
nobling, err := bling.NoBling()
if err != nil {
panic(err)
}
lowbling, err := bling.LowBling()
if err != nil {
panic(err)
}
defaultbling, err := bling.DefaultBling()
if err != nil {
panic(err)
}
highbling, err := bling.HighBling()
if err != nil {
panic(err)
}
app := fiber.New()
app.Get("/", func(c *fiber.Ctx) error {
return c.Redirect("https://getfleek.dev/docs/devbox", http.StatusFound)
})
app.Get("/none", func(c *fiber.Ctx) error {
none := devbox.FromBling(nobling)
tw := tar.NewWriter(c)
defer tw.Close()
files, err := none.Files()
if err != nil {
return err
}
c.Set("Content-Type", "application/x-tar")
err = none.Write(files, tw)
if err != nil {
return err
}
return nil
})
app.Get("/low", func(c *fiber.Ctx) error {
low := devbox.FromBling(lowbling)
tw := tar.NewWriter(c)
defer tw.Close()
files, err := low.Files()
if err != nil {
return err
}
c.Set("Content-Type", "application/x-tar")
err = low.Write(files, tw)
if err != nil {
return err
}
return nil
})
app.Get("/default", func(c *fiber.Ctx) error {
dflt := devbox.FromBling(defaultbling)
tw := tar.NewWriter(c)
defer tw.Close()
files, err := dflt.Files()
if err != nil {
return err
}
c.Set("Content-Type", "application/x-tar")
err = dflt.Write(files, tw)
if err != nil {
return err
}
return nil
})
app.Get("/high", func(c *fiber.Ctx) error {
high := devbox.FromBling(highbling)
tw := tar.NewWriter(c)
defer tw.Close()
files, err := high.Files()
if err != nil {
return err
}
c.Set("Content-Type", "application/x-tar")
err = high.Write(files, tw)
if err != nil {
return err
}
return nil
})
// Setup static files
app.Static("/config", "./static/config")
log.Fatal(app.Listen("0.0.0.0:" + port))
}