aboutsummaryrefslogtreecommitdiff
path: root/resources.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-02-12 11:01:52 +0800
committerRunxi Yu <me@runxiyu.org>2025-02-12 11:01:52 +0800
commit88d054811df785b92b1b76dd91265849af8f29b3 (patch)
tree522a9175290322cbe615ba98acf07a8a81888fcc /resources.go
parentgit_format_patch.go: Remove garbage printf (diff)
downloadforge-88d054811df785b92b1b76dd91265849af8f29b3.tar.gz
forge-88d054811df785b92b1b76dd91265849af8f29b3.tar.zst
forge-88d054811df785b92b1b76dd91265849af8f29b3.zip
*: Migrate to the new path scheme
Diffstat (limited to 'resources.go')
-rw-r--r--resources.go26
1 files changed, 11 insertions, 15 deletions
diff --git a/resources.go b/resources.go
index 30b0de5..4624603 100644
--- a/resources.go
+++ b/resources.go
@@ -13,12 +13,12 @@ import (
//go:embed static/* templates/*
var source_fs embed.FS
-func serve_source() {
- http.Handle("/source/",
- http.StripPrefix(
- "/source/",
- http.FileServer(http.FS(source_fs)),
- ),
+var source_handler http.Handler
+
+func init() {
+ source_handler = http.StripPrefix(
+ "/:/source/",
+ http.FileServer(http.FS(source_fs)),
)
}
@@ -35,16 +35,12 @@ func load_templates() (err error) {
return err
}
-func serve_static() (err error) {
+var static_handler http.Handler
+func init() {
static_fs, err := fs.Sub(resources_fs, "static")
if err != nil {
- return err
+ panic(err)
}
- http.Handle("/static/",
- http.StripPrefix(
- "/static/",
- http.FileServer(http.FS(static_fs)),
- ),
- )
- return nil
+ static_handler = http.StripPrefix("/:/static/", http.FileServer(http.FS(static_fs)))
}
+