diff options
Diffstat (limited to 'handler.go')
-rw-r--r-- | handler.go | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -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} } |