forked from hswaw/hscloud
go/svc/speedtest: bazelify
Change-Id: If83422929432a316c11e25c7dda68d8172f25167
This commit is contained in:
parent
a51df9c2ab
commit
f448f99385
5 changed files with 46 additions and 11 deletions
17
go/svc/speedtest/BUILD
Normal file
17
go/svc/speedtest/BUILD
Normal file
|
@ -0,0 +1,17 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
load("@io_bazel_rules_go//extras:embed_data.bzl", "go_embed_data")
|
||||
|
||||
go_embed_data(
|
||||
name = "static",
|
||||
srcs = ["index.html", "speedtest.js", "speedtest_worker.js"],
|
||||
package = "static",
|
||||
)
|
||||
|
||||
# keep
|
||||
go_library(
|
||||
name = "static_go",
|
||||
srcs = [":static"],
|
||||
importpath = "code.hackerspace.pl/hscloud/go/svc/speedtest/static",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
24
go/svc/speedtest/backend/BUILD.bazel
Normal file
24
go/svc/speedtest/backend/BUILD.bazel
Normal file
|
@ -0,0 +1,24 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["main.go"],
|
||||
importpath = "code.hackerspace.pl/hscloud/go/svc/speedtest/backend",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
"@com_github_golang_glog//:go_default_library",
|
||||
"//go/svc/speedtest:static_go", # keep
|
||||
],
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "backend",
|
||||
embed = [":go_default_library"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["main_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
)
|
|
@ -26,6 +26,8 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
||||
"code.hackerspace.pl/hscloud/go/svc/speedtest/static"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -129,13 +131,13 @@ func main() {
|
|||
json.NewEncoder(w).Encode(res)
|
||||
})
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, "index.html")
|
||||
w.Write(static.Data["go/svc/speedtest/index.html"])
|
||||
})
|
||||
http.HandleFunc("/speedtest.js", func(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, "speedtest.js")
|
||||
w.Write(static.Data["go/svc/speedtest/speedtest.js"])
|
||||
})
|
||||
http.HandleFunc("/speedtest_worker.js", func(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, "speedtest_worker.js")
|
||||
w.Write(static.Data["go/svc/speedtest/speedtest_worker.js"])
|
||||
})
|
||||
|
||||
glog.Infof("Starting up at %v", flagBind)
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
module github.com/q3k/speedtest
|
||||
|
||||
go 1.12
|
||||
|
||||
require github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
|
|
@ -1,3 +0,0 @@
|
|||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/q3k/speedtest v0.0.0-20190630060004-d18f21107a43 h1:0g0AvEkvqQpp7DocEcgryBLSi0LlJh1SR4GteVXC1+o=
|
Loading…
Reference in a new issue