cmd/strelaypoolsrv, lib/api: Factor out static asset serving (#6624)

This commit is contained in:
greatroar
2020-05-10 11:44:34 +02:00
committed by GitHub
parent da99203dcd
commit 06365e5635
7 changed files with 219 additions and 133 deletions
+33
View File
@@ -0,0 +1,33 @@
// Copyright (C) 2014 The Syncthing Authors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
package auto_test
import (
"bytes"
"compress/gzip"
"io/ioutil"
"strings"
"testing"
"github.com/syncthing/syncthing/lib/api/auto"
)
func TestAssets(t *testing.T) {
assets := auto.Assets()
idx, ok := assets["default/index.html"]
if !ok {
t.Fatal("No index.html in compiled in assets")
}
var gr *gzip.Reader
gr, _ = gzip.NewReader(strings.NewReader(idx))
html, _ := ioutil.ReadAll(gr)
if !bytes.Contains(html, []byte("<html")) {
t.Fatal("No html in index.html")
}
}
+10
View File
@@ -0,0 +1,10 @@
// Copyright (C) 2014 The Syncthing Authors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
//go:generate go run ../../../script/genassets.go -o gui.files.go ../../../gui
// Package auto contains auto generated files for web assets.
package auto