aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-02-10 21:17:50 +0800
committerRunxi Yu <me@runxiyu.org>2025-02-10 21:17:50 +0800
commit7fb303be23cfff5ac52684310184576d34099a3e (patch)
tree4e45127da40eef29cd33479fd1bbd85884b3bc74
parenttemplate_funcs: base_name should use path, not filepath (diff)
downloadforge-7fb303be23cfff5ac52684310184576d34099a3e.tar.gz
forge-7fb303be23cfff5ac52684310184576d34099a3e.tar.zst
forge-7fb303be23cfff5ac52684310184576d34099a3e.zip
resources: Serve source and static properly
... except that it won't run because of URL conflicts for now
Diffstat (limited to '')
-rw-r--r--main.go2
-rw-r--r--resources.go17
2 files changed, 18 insertions, 1 deletions
diff --git a/main.go b/main.go
index 81657cd..6c69af4 100644
--- a/main.go
+++ b/main.go
@@ -31,6 +31,8 @@ func main() {
clog.Fatal(1, "Serving static: "+err.Error())
}
+ serve_source()
+
http.HandleFunc("/{$}", handle_index)
http.HandleFunc("/{category_name}/repos/{$}", handle_category_repos)
http.HandleFunc("/{category_name}/repos/{repo_name}/{$}", handle_repo_index)
diff --git a/resources.go b/resources.go
index 860971c..30b0de5 100644
--- a/resources.go
+++ b/resources.go
@@ -7,6 +7,21 @@ import (
"net/http"
)
+//go:embed .gitignore LICENSE README.md
+//go:embed *.go go.mod go.sum
+//go:embed *.scfg
+//go:embed static/* templates/*
+var source_fs embed.FS
+
+func serve_source() {
+ http.Handle("/source/",
+ http.StripPrefix(
+ "/source/",
+ http.FileServer(http.FS(source_fs)),
+ ),
+ )
+}
+
//go:embed templates/* static/*
var resources_fs embed.FS
@@ -25,7 +40,7 @@ func serve_static() (err error) {
if err != nil {
return err
}
- http.Handle("/static/{name}",
+ http.Handle("/static/",
http.StripPrefix(
"/static/",
http.FileServer(http.FS(static_fs)),