Removed go-bindata-assetfs and replaced with statik
This commit is contained in:
committed by
ncthompson
parent
790b05f90f
commit
206159cdea
@@ -1,39 +1,26 @@
|
||||
package frontend
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"github.com/rakyll/statik/fs"
|
||||
|
||||
assetfs "github.com/elazarl/go-bindata-assetfs"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type binaryFileSystem struct {
|
||||
fs http.FileSystem
|
||||
type static struct {
|
||||
http.FileSystem
|
||||
}
|
||||
|
||||
func (b *binaryFileSystem) Open(name string) (http.File, error) {
|
||||
return b.fs.Open(name)
|
||||
}
|
||||
|
||||
func (b *binaryFileSystem) Exists(prefix string, filepath string) bool {
|
||||
|
||||
if p := strings.TrimPrefix(filepath, prefix); len(p) < len(filepath) {
|
||||
if _, err := b.fs.Open(p); err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
func NewStatic() http.Handler {
|
||||
statikFs, err := fs.New()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func BinaryFileSystem(root string) *binaryFileSystem {
|
||||
fs := &assetfs.AssetFS{
|
||||
Asset: Asset,
|
||||
AssetDir: AssetDir,
|
||||
AssetInfo: AssetInfo,
|
||||
Prefix: root,
|
||||
}
|
||||
return &binaryFileSystem{
|
||||
fs,
|
||||
return &static{
|
||||
FileSystem: statikFs,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *static) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
http.FileServer(s).ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,2 +0,0 @@
|
||||
#!/bin/bash
|
||||
go-bindata-assetfs -pkg="frontend" css/ js/ root/
|
||||
13
frontend/statik.go
Normal file
13
frontend/statik.go
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user