File tree 6 files changed +40
-40
lines changed
6 files changed +40
-40
lines changed Original file line number Diff line number Diff line change @@ -334,7 +334,7 @@ func New(options *Options) *API {
334
334
r .Get ("/state" , api .workspaceBuildState )
335
335
})
336
336
})
337
- r .NotFound (site .DefaultHandler ( ).ServeHTTP )
337
+ r .NotFound (site .Handler ( site . FS () ).ServeHTTP )
338
338
339
339
return api
340
340
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
- //go:build embed
2
- // +build embed
3
-
4
1
package site
5
2
6
3
import (
7
4
"bytes"
8
- "embed"
9
5
"fmt"
10
6
"io"
11
7
"io/fs"
@@ -21,26 +17,6 @@ import (
21
17
"golang.org/x/xerrors"
22
18
)
23
19
24
- // The `embed` package ignores recursively including directories
25
- // that prefix with `_`. Wildcarding nested is janky, but seems to
26
- // work quite well for edge-cases.
27
- //go:embed out
28
- //go:embed out/bin/*
29
- var site embed.FS
30
-
31
- func DefaultHandler () http.Handler {
32
- // the out directory is where webpack builds are created. It is in the same
33
- // directory as this file (package site).
34
- siteFS , err := fs .Sub (site , "out" )
35
-
36
- if err != nil {
37
- // This can't happen... Go would throw a compilation error.
38
- panic (err )
39
- }
40
-
41
- return Handler (siteFS )
42
- }
43
-
44
20
// Handler returns an HTTP handler for serving the static site.
45
21
func Handler (fileSystem fs.FS ) http.Handler {
46
22
// html files are handled by a text/template. Non-html files
Original file line number Diff line number Diff line change
1
+ //go:build embed
2
+ // +build embed
3
+
4
+ package site
5
+
6
+ import (
7
+ "embed"
8
+ "io/fs"
9
+ )
10
+
11
+ //go:embed out
12
+ //go:embed out/bin/*
13
+ var site embed.FS
14
+
15
+ func FS () fs.FS {
16
+ // the out directory is where webpack builds are created. It is in the same
17
+ // directory as this file (package site).
18
+ out , err := fs .Sub (site , "out" )
19
+ if err != nil {
20
+ // This can't happen... Go would throw a compilation error.
21
+ panic (err )
22
+ }
23
+ return out
24
+ }
Original file line number Diff line number Diff line change
1
+ //go:build !embed
2
+ // +build !embed
3
+
4
+ package site
5
+
6
+ import (
7
+ "embed"
8
+ "io/fs"
9
+ )
10
+
11
+ var slim embed.FS
12
+
13
+ func FS () fs.FS {
14
+ return slim
15
+ }
Original file line number Diff line number Diff line change 1
- //go:build embed
2
- // +build embed
3
-
4
1
package site_test
5
2
6
3
import (
You can’t perform that action at this time.
0 commit comments