From 509ae1968bb9cf995cfd2f4345ab9f4b92db42a5 Mon Sep 17 00:00:00 2001 From: Arnas Udovic Date: Wed, 28 Jun 2023 08:10:07 +0300 Subject: [PATCH] guess mimetype --- README.md | 7 ++++++- main.go | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 869b639..8bf2dda 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,15 @@ My capsule in Gemini space. Built with zord-tree support ## TODO -* add image or other file not `gmi` download +* main.go:173 add content type by extension +* refactor layout +* remove capsule title from simple page * security * citata from some file +* add pagehint counter in abcex +* add gallery categories. index.md with secret to dynamic generators on build __DONE__ +* add image or other file not `gmi` download * feed * add category view * add tag view diff --git a/main.go b/main.go index f89fa30..b266fa8 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,8 @@ import ( "google.golang.org/grpc/credentials/insecure" "io" "log" + "mime" + "path" "regexp" "strings" "time" @@ -169,8 +171,7 @@ func downloadAttachment(w gemini.ResponseWriter, r *gemini.Request, client TreeM return } - //w.SetMediaType(http.DetectContentType([]byte(response.Content))) - w.SetMediaType("image/png") + w.SetMediaType(mime.TypeByExtension(path.Ext(filePath))) for { chunkResponse, err := response.Recv() if err == io.EOF {