aboutsummaryrefslogtreecommitdiff
path: root/handler.go
diff options
context:
space:
mode:
Diffstat (limited to 'handler.go')
-rw-r--r--handler.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/handler.go b/handler.go
index 75a8d2b..e484b27 100644
--- a/handler.go
+++ b/handler.go
@@ -3,6 +3,7 @@ package main
import (
"fmt"
"log"
+ "mime"
"net/url"
"os"
"path/filepath"
@@ -11,6 +12,11 @@ import (
gemini "git.sr.ht/~yotam/go-gemini"
)
+func absPathMime(path string) string {
+ ext := filepath.Ext(path)
+ return mime.TypeByExtension(ext)
+}
+
// Handler is the main handler of the server
type Handler struct {
cfg Config
@@ -75,5 +81,6 @@ func (h Handler) Handle(r gemini.Request) gemini.Response {
return gemini.ErrorResponse(err)
}
- return gemini.Response{Status: gemini.StatusSuccess, Meta: "text/gemini", Body: file}
+ meta := absPathMime(itemPath)
+ return gemini.Response{Status: gemini.StatusSuccess, Meta: meta, Body: file}
}