diff --git a/go.mod b/go.mod index 6ebc431..42b9b0a 100644 --- a/go.mod +++ b/go.mod @@ -7,5 +7,5 @@ require ( golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4 golang.org/x/net v0.0.0-20190620200207-3b0461eec859 humungus.tedunangst.com/r/go-sqlite3 v1.1.3 - humungus.tedunangst.com/r/webs v0.6.6 + humungus.tedunangst.com/r/webs v0.6.7 ) diff --git a/go.sum b/go.sum index 6d8b6ad..a5bc4f2 100644 --- a/go.sum +++ b/go.sum @@ -23,3 +23,5 @@ humungus.tedunangst.com/r/go-sqlite3 v1.1.3 h1:G2N4wzDS0NbuvrZtQJhh4F+3X+s7BF8b9 humungus.tedunangst.com/r/go-sqlite3 v1.1.3/go.mod h1:FtEEmQM7U2Ey1TuEEOyY1BmphTZnmiEjPsNLEAkpf/M= humungus.tedunangst.com/r/webs v0.6.6 h1:qepe+N9waCqLzOwhSws5pxpwSxNxdYRktJB1gY8Q3NQ= humungus.tedunangst.com/r/webs v0.6.6/go.mod h1:Ho+nmafD/aUWF7LnH+Yl2/b0ob7f2pCkXm4onteWvLE= +humungus.tedunangst.com/r/webs v0.6.7 h1:VE556AXIwCVQRraVc36ild+b7ET30aoJNCVykDLqMPo= +humungus.tedunangst.com/r/webs v0.6.7/go.mod h1:Ho+nmafD/aUWF7LnH+Yl2/b0ob7f2pCkXm4onteWvLE= diff --git a/web.go b/web.go index cc3f49c..ea98ce5 100644 --- a/web.go +++ b/web.go @@ -21,7 +21,6 @@ import ( "html" "html/template" "io" - "io/ioutil" "log" notrand "math/rand" "net/http" @@ -1355,11 +1354,17 @@ func avatate(w http.ResponseWriter, r *http.Request) { } func servecss(w http.ResponseWriter, r *http.Request) { - data, _ := ioutil.ReadFile("views" + r.URL.Path) - s := css.Process(string(data)) - w.Header().Set("Cache-Control", "max-age=7776000") + fd, err := os.Open("views" + r.URL.Path) + if err != nil { + http.NotFound(w, r) + return + } + w.Header().Set("Cache-Control", "max-age=0") w.Header().Set("Content-Type", "text/css; charset=utf-8") - w.Write([]byte(s)) + err = css.Filter(fd, w) + if err != nil { + log.Printf("error filtering css: %s", err) + } } func serveasset(w http.ResponseWriter, r *http.Request) { w.Header().Set("Cache-Control", "max-age=7776000")