-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add back dev build tag for local file access without embedding
- Loading branch information
Showing
9 changed files
with
81 additions
and
54 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
// +build !dev | ||
|
||
package web | ||
|
||
import ( | ||
"embed" | ||
"io/fs" | ||
"log" | ||
"net/http" | ||
) | ||
|
||
// Production can be used to determain different aspects at compile time (like hot template reloading) | ||
const Production = true | ||
|
||
var ( | ||
Assets http.FileSystem | ||
Templates http.FileSystem | ||
) | ||
|
||
// correct the paths by stripping their prefixes | ||
func init() { | ||
var err error | ||
|
||
prefixedAssets, err := fs.Sub(embedAssets, "assets") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
Assets = http.FS(prefixedAssets) | ||
|
||
prefixedTemplates, err := fs.Sub(embedTemplates, "templates") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
Templates = http.FS(prefixedTemplates) | ||
} | ||
|
||
//go:embed templates/* | ||
var embedTemplates embed.FS | ||
|
||
//go:embed assets/* | ||
var embedAssets embed.FS |
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
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
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 was deleted.
Oops, something went wrong.
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