seems to embed files
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2020-10-28 16:46:22 -07:00
parent b07a0dd9d2
commit c19f9d0eb2
8 changed files with 44 additions and 4 deletions

7
httpserver/embed.go Normal file
View File

@@ -0,0 +1,7 @@
package httpserver
import "github.com/lu4p/binclude"
//go:generate binclude -gzip
var embeddedAssets = binclude.Include("web")

View File

@@ -1,12 +1,17 @@
package httpserver
import (
"fmt"
"net/http"
"github.com/rs/zerolog/log"
)
func (s *server) handleIndex() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "hello world")
content, err := s.staticFiles.ReadFile("web/index.html")
if err != nil {
log.Fatal().Err(err).Send()
}
w.Write(content)
}
}

View File

@@ -10,6 +10,7 @@ import (
"syscall"
"time"
"github.com/lu4p/binclude"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/spf13/viper"
@@ -41,6 +42,7 @@ type server struct {
cancelFunc context.CancelFunc
httpServer *http.Server
router *chi.Mux
staticFiles *binclude.FileSystem
}
func NewServer(options ...func(s *server)) *server {
@@ -61,6 +63,7 @@ func Run(appname, version, buildarch string) int {
i.version = version
}
i.buildarch = buildarch
i.staticFiles = BinFS
})
// this does nothing if SENTRY_DSN is unset in env.

12
httpserver/web/index.html Normal file
View File

@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Title</title>
<link rel="stylesheet" href="/s/css/style.css">
</head>
<body>
<h1>Hello, world!</h1>
<script src="/s/js/scripts.js"></script>
</body>
</html>