-
-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Utilize builtin go "embed" package to embed all static files needed b…
…y internal viewer UI
- Loading branch information
mapl
committed
Jul 31, 2021
1 parent
4ab36cc
commit 1f3156c
Showing
8 changed files
with
88 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// +build !noViewer | ||
// +build !noViewer,!go1.16 | ||
|
||
package server | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// +build !noViewer,go1.16 | ||
|
||
package server | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/dimfeld/httptreemux" | ||
"github.com/go-spatial/tegola/observability" | ||
"github.com/go-spatial/tegola/ui" | ||
) | ||
|
||
// setupViewer in this file is used for registering the viewer routes when the viewer | ||
// is included in the build (default) | ||
func setupViewer(o observability.Interface, group *httptreemux.Group) { | ||
|
||
group.UsingContext().Handler(observability.InstrumentViewerHandler(http.MethodGet, "/", o, http.FileServer(ui.GetDistFileSystem()))) | ||
group.UsingContext().Handler(observability.InstrumentViewerHandler(http.MethodGet, "/*path", o, http.FileServer(ui.GetDistFileSystem()))) | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package ui | ||
|
||
import ( | ||
"embed" | ||
"io/fs" | ||
"net/http" | ||
|
||
"github.com/go-spatial/tegola/internal/log" | ||
) | ||
|
||
//Embed UI dist Folder recursively | ||
//go:embed dist/* | ||
var dist embed.FS | ||
|
||
func GetDistFileSystem() http.FileSystem { | ||
distfs, err := fs.Sub(dist, "dist") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
return http.FS(distfs) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters