Initial commit

This commit is contained in:
nemunaire 2020-03-04 12:07:12 +01:00
commit f073e69417
28 changed files with 2564 additions and 0 deletions

73
static.go Normal file
View file

@ -0,0 +1,73 @@
// +build !dev
package main
import (
"fmt"
"net/http"
"path"
"github.com/julienschmidt/httprouter"
)
//go:generate go-bindata -ignore "\\.go|\\.less" -pkg "main" -o "bindata.go" htdocs/...
//go:generate go fmt bindata.go
func init() {
Router().GET("/", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
if data, err := Asset("htdocs/index.html"); err != nil {
fmt.Fprintf(w, "{\"errmsg\":%q}", err)
} else {
w.Write(data)
}
})
Router().GET("/auth", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
if data, err := Asset("htdocs/index.html"); err != nil {
fmt.Fprintf(w, "{\"errmsg\":%q}", err)
} else {
w.Write(data)
}
})
Router().GET("/css/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
w.Header().Set("Content-Type", "text/css")
if data, err := Asset(path.Join("htdocs", r.URL.Path)); err != nil {
http.NotFound(w, r)
} else {
w.Write(data)
}
})
Router().GET("/fonts/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
if data, err := Asset(path.Join("htdocs", r.URL.Path)); err != nil {
http.NotFound(w, r)
} else {
w.Write(data)
}
})
Router().GET("/img/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
if data, err := Asset(path.Join("htdocs", r.URL.Path)); err != nil {
http.NotFound(w, r)
} else {
w.Write(data)
}
})
Router().GET("/js/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
w.Header().Set("Content-Type", "text/javascript")
if data, err := Asset(path.Join("htdocs", r.URL.Path)); err != nil {
http.NotFound(w, r)
} else {
w.Write(data)
}
})
Router().GET("/views/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
w.Header().Set("Content-Type", "text/html")
if data, err := Asset(path.Join("htdocs", r.URL.Path)); err != nil {
http.NotFound(w, r)
} else {
w.Write(data)
}
})
}
func sanitizeStaticOptions() error {
return nil
}