-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
51 lines (41 loc) · 808 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
45
46
47
48
49
50
51
package main
import (
"embed"
"io/fs"
"net/http"
"os"
"github.com/aaronvb/request_hole/cmd"
)
//go:embed web/build
var embededFiles embed.FS
var staticFS http.FileSystem
var (
version = "dev"
commit = "none"
date = "unknown"
repo = "github.com/aaronvb/request_hole"
builtBy = "dev"
)
func main() {
buildInfo := map[string]string{
"version": version,
"commit": commit,
"date": date,
"repo": repo,
"builtBy": builtBy,
}
// Set file system for the web UI
useOSFS := version == "dev"
staticFS = getFileSystem(useOSFS)
cmd.Execute(buildInfo, staticFS)
}
func getFileSystem(useOS bool) http.FileSystem {
if useOS {
return http.FS(os.DirFS("web/build"))
}
fsys, err := fs.Sub(embededFiles, "web/build")
if err != nil {
panic(err)
}
return http.FS(fsys)
}