Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
Embed web view templates to the binary
Browse files Browse the repository at this point in the history
  • Loading branch information
agis committed Apr 18, 2018
1 parent 13b2c46 commit 5b67989
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 10 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
*.prof
*.pyc

config.json
fabfile.py

/mistry
/mistryd

cmd/mistryd/statik
config.json
fabfile.py
vendor/
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ install: fmt test
build: mistryd mistry

mistryd:
go generate ./...
$(BUILDCMD) -o $(SERVER) cmd/mistryd/*.go

mistry:
Expand Down
14 changes: 10 additions & 4 deletions cmd/mistryd/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions cmd/mistryd/Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@
[[constraint]]
name = "github.com/urfave/cli"
version = "1.20.0"

[[constraint]]
name = "github.com/rakyll/statik"
version = "0.1.1"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 10 additions & 3 deletions cmd/mistryd/server.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:generate statik -src=./public -f
package main

import (
Expand All @@ -16,8 +17,8 @@ import (

"sync"

"github.com/alecthomas/template"

"github.com/rakyll/statik/fs"
_ "github.com/skroutz/mistry/cmd/mistryd/statik"
"github.com/skroutz/mistry/pkg/broker"
"github.com/skroutz/mistry/pkg/tailer"
"github.com/skroutz/mistry/pkg/types"
Expand Down Expand Up @@ -56,7 +57,13 @@ func NewServer(cfg *Config, logger *log.Logger) (*Server, error) {

s := new(Server)
mux := http.NewServeMux()
mux.Handle("/", http.StripPrefix("/", http.FileServer(http.Dir("public"))))

statikFS, err := fs.New()
if err != nil {
logger.Fatal(err)
}

mux.Handle("/", http.StripPrefix("/", http.FileServer(statikFS)))
mux.HandleFunc("/jobs", s.HandleNewJob)
mux.HandleFunc("/index/", s.HandleIndex)
mux.HandleFunc("/job/", s.HandleShowJob)
Expand Down

0 comments on commit 5b67989

Please sign in to comment.