2021-04-20 09:45:05 -05:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
2023-02-02 17:15:17 -08:00
|
|
|
|
2021-09-27 16:24:00 -04:00
|
|
|
//go:build ui
|
2021-04-20 09:45:05 -05:00
|
|
|
// +build ui
|
|
|
|
|
|
|
|
|
|
package ui
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"embed"
|
|
|
|
|
"io/fs"
|
|
|
|
|
"net/http"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Sadly we can't embed this into the embed line, but we use it elsewhere
|
|
|
|
|
const contentDir = ".tmp/boundary-ui/ui/admin/dist"
|
|
|
|
|
|
|
|
|
|
// content is our static web server content.
|
2022-08-25 09:12:24 -07:00
|
|
|
//
|
2021-04-20 09:45:05 -05:00
|
|
|
//go:embed .tmp/boundary-ui/ui/admin/dist
|
|
|
|
|
var content embed.FS
|
|
|
|
|
|
|
|
|
|
func Handler() http.Handler {
|
|
|
|
|
return http.FileServer(httpFileSystem())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func httpFileSystem() http.FileSystem {
|
|
|
|
|
return http.FS(fileSystem())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func fileSystem() fs.FS {
|
|
|
|
|
// Remove the root
|
|
|
|
|
f, err := fs.Sub(content, contentDir)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
return f
|
|
|
|
|
}
|