summaryrefslogtreecommitdiffstats
path: root/roseh.moe.go
diff options
context:
space:
mode:
Diffstat (limited to 'roseh.moe.go')
-rw-r--r--roseh.moe.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/roseh.moe.go b/roseh.moe.go
index 0556269..ce66f73 100644
--- a/roseh.moe.go
+++ b/roseh.moe.go
@@ -17,6 +17,8 @@ import (
var (
port = flag.Int("port", 42069, "port to listen on")
https = flag.Bool("https", false, "use https")
+
+ serverStartTime = time.Now()
)
//go:embed templates/404.html.template
@@ -49,15 +51,14 @@ func index(w http.ResponseWriter, _ *http.Request) {
var staticFiles embed.FS
func static(w http.ResponseWriter, r *http.Request) {
- f, err := staticFiles.Open(strings.TrimPrefix(r.URL.Path, "/"))
+ fileName := strings.TrimPrefix(r.URL.Path, "/")
+ f, err := staticFiles.Open(fileName)
if err != nil {
notFound(w, r)
return
}
defer f.Close()
- if _, err := io.Copy(w, f); err != nil {
- log.Printf("Warning: static: %s", err)
- }
+ http.ServeContent(w, r, fileName, serverStartTime, f.(io.ReadSeeker))
}
func main() {