Parcourir la Source

Fix serving PDFs

They were converted to text and served in a `<pre>` element, because I
did not consider non-text things.  Now they are just served fresh from
the disk.

Maybe we should switch the logic around so that non-html is the default,
but... not yet. :)

(I usually don't write code that I don't need yet, so... that code isn't
here yet.)
Lu Stadler 5 ans auparavant
Parent
commit
206864fd38
1 fichiers modifiés avec 5 ajouts et 0 suppressions
  1. 5 0
      go/tmpview/tmpview.go

+ 5 - 0
go/tmpview/tmpview.go

@ -39,6 +39,11 @@ func main() {
39 39
				log.Println(err)
40 40
			}
41 41
42
			if strings.HasSuffix(strings.ToLower(fileName), ".pdf") {
43
				w.Write(data)
44
				return
45
			}
46
42 47
			style := `body { max-width: 50em; margin: 0 auto; }`
43 48
			fmt.Fprintf(w, "<!doctype html><html><head><meta charset=\"utf-8\" /><title>%s</title><style>%s</style></head><body>\n\n\n", fileName, style)
44 49
			switch {