Work on Maatma interface

This commit is contained in:
nemunaire 2019-03-13 22:06:35 +01:00 committed by Pierre-Olivier Mercier
commit e965705bfe
6 changed files with 401 additions and 13 deletions

View file

@ -4,6 +4,7 @@ import (
"fmt"
"net/http"
"path"
"strings"
"github.com/julienschmidt/httprouter"
)
@ -12,21 +13,6 @@ import (
//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("/dashboard/", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
if data, err := Asset("htdocs/dashboard.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 {
@ -65,4 +51,95 @@ func init() {
w.Write(data)
}
})
Router().GET("/dashboard/", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
if data, err := Asset("htdocs/dashboard.html"); err != nil {
fmt.Fprintf(w, "{\"errmsg\":%q}", err)
} else {
w.Write(data)
}
})
Router().GET("/dashboard/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", strings.TrimPrefix(r.URL.Path, "/dashboard"))); err != nil {
http.NotFound(w, r)
} else {
w.Write(data)
}
})
Router().GET("/dashboard/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", strings.TrimPrefix(r.URL.Path, "/dashboard"))); err != nil {
http.NotFound(w, r)
} else {
w.Write(data)
}
})
Router().GET("/maatma/", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
if data, err := Asset("htdocs/maatma.html"); err != nil {
fmt.Fprintf(w, "{\"errmsg\":%q}", err)
} else {
w.Write(data)
}
})
Router().GET("/maatma/auth", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
if data, err := Asset("htdocs/maatma.html"); err != nil {
fmt.Fprintf(w, "{\"errmsg\":%q}", err)
} else {
w.Write(data)
}
})
Router().GET("/maatma/domains", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
if data, err := Asset("htdocs/maatma.html"); err != nil {
fmt.Fprintf(w, "{\"errmsg\":%q}", err)
} else {
w.Write(data)
}
})
Router().GET("/maatma/tunnels", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
if data, err := Asset("htdocs/maatma.html"); err != nil {
fmt.Fprintf(w, "{\"errmsg\":%q}", err)
} else {
w.Write(data)
}
})
Router().GET("/maatma/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", strings.TrimPrefix(r.URL.Path, "/maatma"))); err != nil {
http.NotFound(w, r)
} else {
w.Write(data)
}
})
Router().GET("/maatma/fonts/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
if data, err := Asset(path.Join("htdocs", strings.TrimPrefix(r.URL.Path, "/maatma"))); err != nil {
http.NotFound(w, r)
} else {
w.Write(data)
}
})
Router().GET("/maatma/img/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
if data, err := Asset(path.Join("htdocs", strings.TrimPrefix(r.URL.Path, "/maatma"))); err != nil {
http.NotFound(w, r)
} else {
w.Write(data)
}
})
Router().GET("/maatma/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", strings.TrimPrefix(r.URL.Path, "/maatma"))); err != nil {
http.NotFound(w, r)
} else {
w.Write(data)
}
})
Router().GET("/maatma/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", strings.TrimPrefix(r.URL.Path, "/maatma"))); err != nil {
http.NotFound(w, r)
} else {
w.Write(data)
}
})
}