mirror of https://github.com/perkeep/perkeep.git
website: serve non-HTML files as raw bytes
The website has several non-HTML files that mostly serve as examples (eg: https://camlistore.org/doc/json-signing/example/signing-before.camli). Today these files are parsed and rendered the same as HTML files, which is particularly bad for these json-signing examples. Instead, they should be served raw, without any interpretation. Change-Id: I09f7de130e55da7b2e585f1a110bbbf391f2279f
This commit is contained in:
parent
066db0952c
commit
3cc1efc75e
|
@ -369,6 +369,11 @@ var markdownRenderer = blackfriday.HtmlRenderer(markdownHTMLFlags, "", "")
|
|||
|
||||
// serveFile serves a file from disk, converting any markdown to HTML.
|
||||
func serveFile(rw http.ResponseWriter, req *http.Request, relPath, absPath string) {
|
||||
if !strings.HasSuffix(absPath, ".html") && !strings.HasSuffix(absPath, ".md") {
|
||||
http.ServeFile(rw, req, absPath)
|
||||
return
|
||||
}
|
||||
|
||||
data, err := ioutil.ReadFile(absPath)
|
||||
if err != nil {
|
||||
serveError(rw, req, absPath, err)
|
||||
|
|
Loading…
Reference in New Issue