From 8c751548543a9b4b4dfd7fc6de0a86e13510ad27 Mon Sep 17 00:00:00 2001 From: studiokaiji Date: Fri, 20 Oct 2023 04:24:10 +0900 Subject: [PATCH] =?UTF-8?q?getContentType=E3=82=92=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hostr/cmd/tools/getContentType.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 hostr/cmd/tools/getContentType.go diff --git a/hostr/cmd/tools/getContentType.go b/hostr/cmd/tools/getContentType.go new file mode 100644 index 0000000..b785ad0 --- /dev/null +++ b/hostr/cmd/tools/getContentType.go @@ -0,0 +1,20 @@ +package tools + +import ( + "fmt" + + "github.com/studiokaiji/nostr-webhost/hostr/cmd/consts" +) + +func GetContentType(kind int) (string, error) { + switch kind { + case consts.KindWebhostHTML | consts.KindWebhostReplaceableHTML: + return "text/html; charset=utf-8", nil + case consts.KindWebhostCSS | consts.KindWebhostReplaceableCSS: + return "text/css; charset=utf-8", nil + case consts.KindWebhostJS | consts.KindWebhostReplaceableJS: + return "text/javascript; charset=utf-8", nil + default: + return "", fmt.Errorf("Invalid Kind") + } +}