DirList: Better log message

Previously: "Serving content: /dir/index.gmi.gmi"
Now       : "Serving content: /dir/"
This commit is contained in:
hedy 2022-02-15 10:48:42 +08:00
parent 66b01724c0
commit efbf17cfd6
Signed by: hedy
GPG Key ID: B51B5A8D1B176372
1 changed files with 2 additions and 2 deletions

View File

@ -282,7 +282,7 @@ func serveFile(conn io.ReadWriteCloser, reqPath, path string, conf *Config) {
sendResponseHeader(conn, statusServerError, "Error generating directory listing")
return
}
path += ".gmi" // OOF, this is just to have the text/gemini meta later lol
path = strings.TrimSuffix(path, "index.gmi")
serveContent(conn, content, path)
return
}
@ -316,7 +316,7 @@ func serveFile(conn io.ReadWriteCloser, reqPath, path string, conf *Config) {
func serveContent(conn io.ReadWriteCloser, content []byte, path string) {
// MIME
meta := http.DetectContentType(content)
if strings.HasSuffix(path, ".gmi") {
if strings.HasSuffix(path, ".gmi") || strings.HasSuffix(path, "/") {
meta = "text/gemini; lang=en; charset=utf-8" // TODO: configure custom meta string
}