File tree Expand file tree Collapse file tree 6 files changed +40
-40
lines changed Expand file tree Collapse file tree 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 {
334334 r .Get ("/state" , api .workspaceBuildState )
335335 })
336336 })
337- r .NotFound (site .DefaultHandler ( ).ServeHTTP )
337+ r .NotFound (site .Handler ( site . FS () ).ServeHTTP )
338338
339339 return api
340340}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1- //go:build embed
2- // +build embed
3-
41package site
52
63import (
74 "bytes"
8- "embed"
95 "fmt"
106 "io"
117 "io/fs"
@@ -21,26 +17,6 @@ import (
2117 "golang.org/x/xerrors"
2218)
2319
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-
4420// Handler returns an HTTP handler for serving the static site.
4521func Handler (fileSystem fs.FS ) http.Handler {
4622 // 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-
41package site_test
52
63import (
You can’t perform that action at this time.
0 commit comments