mirror of
https://github.com/sosedoff/pgweb.git
synced 2024-12-15 11:52:12 +03:00
Refactor mime type detection by using path/filepath package
This commit is contained in:
parent
338df85549
commit
b6d1b2502e
16
api.go
16
api.go
@ -4,6 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -12,19 +13,16 @@ type Error struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func assetContentType(name string) string {
|
func assetContentType(name string) string {
|
||||||
if strings.Contains(name, ".css") {
|
switch filepath.Ext(name) {
|
||||||
|
case ".css":
|
||||||
return "text/css"
|
return "text/css"
|
||||||
}
|
case ".js":
|
||||||
|
|
||||||
if strings.Contains(name, ".js") {
|
|
||||||
return "application/javascript"
|
return "application/javascript"
|
||||||
}
|
case ".icon":
|
||||||
|
|
||||||
if strings.Contains(name, ".icon") {
|
|
||||||
return "image/x-icon"
|
return "image/x-icon"
|
||||||
|
default:
|
||||||
|
return "text/plain"
|
||||||
}
|
}
|
||||||
|
|
||||||
return "text/plain"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func API_Home(c *gin.Context) {
|
func API_Home(c *gin.Context) {
|
||||||
|
Loading…
Reference in New Issue
Block a user