fix(backend): return 404 if custom asset files are missing

This commit is contained in:
Łukasz Mierzwa
2018-11-04 11:53:42 +00:00
parent 99fe6afe5d
commit 7c8b9b3dfe
2 changed files with 6 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ package main
import (
"errors"
"fmt"
"html/template"
"net/http"
"os"
@@ -81,7 +82,7 @@ func serverFileOrEmpty(path string, contentType string, c *gin.Context) {
return
}
if _, err := os.Stat(path); os.IsNotExist(err) {
c.Data(200, contentType, nil)
c.Data(404, contentType, []byte(fmt.Sprintf("%s not found", path)))
return
}
c.File(path)

View File

@@ -33,15 +33,15 @@ func TestCustomizationAssets(t *testing.T) {
{
customJS: "foo/bar/custom.js",
path: "/custom.js",
code: 200,
body: "",
code: 404,
body: "foo/bar/custom.js not found",
mime: "application/javascript",
},
{
customCSS: "foo/bar/custom.css",
path: "/custom.css",
code: 200,
body: "",
code: 404,
body: "foo/bar/custom.css not found",
mime: "text/css",
},
{