~blu/artemis

1146fac0df973796feea1768b826a4ef8a9324a0 — Bryant Conquest 1 year, 9 months ago 8f77171
set content type based on fileending
1 files changed, 5 insertions(+), 3 deletions(-)

M main.go
M main.go => main.go +5 -3
@@ 7,6 7,8 @@ import (
	"log"
	"net/http"
	"strings"
  "path/filepath"
  "mime"

	"tailscale.com/tsweb"



@@ 58,9 60,9 @@ func AssetHandler(h *Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		path := strings.TrimLeft(r.URL.Path, "/assets")

		if strings.HasSuffix(path, ".svg") {
			w.Header().Set("Content-Type", "image/svg+xml")
		}
    if ext := mime.TypeByExtension(filepath.Ext(path)); ext != "" {
      w.Header().Set("Content-Type", ext)
    }

		etag := r.Header.Get("If-None-Match")
		_, ok := h.Cache.Files.Load(etag)