From 99fe6afe5d6279a9a8c466d9d231294a60673c18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Thu, 27 Dec 2018 15:58:22 +0100 Subject: [PATCH 1/2] chore(build): store file metadata when generating binary assets This was disabled because bindata_assetfs.go file was stored in git, not it's not so we can re-enable it and get accurate Last-Modified headers in HTTP responses --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index cee5162d2..dd617782f 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ endif touch $@ bindata_assetfs.go: .build/deps-build-go.ok .build/artifacts-bindata_assetfs.$(GO_BINDATA_MODE) .build/artifacts-ui.ok - go-bindata-assetfs -o bindata_assetfs.go -nometadata ui/build/... ui/src/... + go-bindata-assetfs -o bindata_assetfs.go ui/build/... ui/src/... $(NAME): .build/deps-build-go.ok go.mod bindata_assetfs.go $(SOURCES) GO111MODULE=on go build -ldflags "-X main.version=$(VERSION)" From 7c8b9b3dfedcf25c3a1b5c4bd6005b065ec7f32e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Sun, 4 Nov 2018 11:53:42 +0000 Subject: [PATCH 2/2] fix(backend): return 404 if custom asset files are missing --- assets.go | 3 ++- assets_test.go | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/assets.go b/assets.go index 4a51216c5..b50da0e36 100644 --- a/assets.go +++ b/assets.go @@ -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) diff --git a/assets_test.go b/assets_test.go index ccffc0550..148efed94 100644 --- a/assets_test.go +++ b/assets_test.go @@ -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", }, {