2018-02-20 12:49:03 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-02-24 03:58:43 +00:00
|
|
|
"fmt"
|
2018-02-20 12:49:03 +00:00
|
|
|
"net/http"
|
|
|
|
"path"
|
2019-03-13 21:06:35 +00:00
|
|
|
"strings"
|
2018-02-20 12:49:03 +00:00
|
|
|
|
|
|
|
"github.com/julienschmidt/httprouter"
|
|
|
|
)
|
|
|
|
|
2019-02-24 03:58:43 +00:00
|
|
|
//go:generate go-bindata -ignore "\\.go|\\.less" -pkg "main" -o "bindata.go" htdocs/...
|
|
|
|
//go:generate go fmt bindata.go
|
|
|
|
|
2018-02-20 12:49:03 +00:00
|
|
|
func init() {
|
2019-03-13 21:06:35 +00:00
|
|
|
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)
|
2019-02-24 03:58:43 +00:00
|
|
|
} else {
|
|
|
|
w.Write(data)
|
|
|
|
}
|
2018-02-20 12:49:03 +00:00
|
|
|
})
|
2019-03-13 21:06:35 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2019-03-13 18:10:14 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
})
|
2019-03-13 21:06:35 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
})
|
2019-02-24 03:58:43 +00:00
|
|
|
|
2019-03-13 21:06:35 +00:00
|
|
|
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) {
|
2019-02-24 03:58:43 +00:00
|
|
|
w.Header().Set("Content-Type", "text/css")
|
2019-03-13 21:06:35 +00:00
|
|
|
if data, err := Asset(path.Join("htdocs", strings.TrimPrefix(r.URL.Path, "/maatma"))); err != nil {
|
2019-02-24 03:58:43 +00:00
|
|
|
http.NotFound(w, r)
|
|
|
|
} else {
|
|
|
|
w.Write(data)
|
|
|
|
}
|
2018-02-20 12:49:03 +00:00
|
|
|
})
|
2019-03-13 21:06:35 +00:00
|
|
|
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 {
|
2019-02-24 03:58:43 +00:00
|
|
|
http.NotFound(w, r)
|
|
|
|
} else {
|
|
|
|
w.Write(data)
|
|
|
|
}
|
2018-02-20 12:49:03 +00:00
|
|
|
})
|
2019-03-13 21:06:35 +00:00
|
|
|
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 {
|
2019-02-24 03:58:43 +00:00
|
|
|
http.NotFound(w, r)
|
|
|
|
} else {
|
|
|
|
w.Write(data)
|
|
|
|
}
|
2018-02-20 12:49:03 +00:00
|
|
|
})
|
2019-03-13 21:06:35 +00:00
|
|
|
Router().GET("/maatma/js/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
2019-02-24 03:58:43 +00:00
|
|
|
w.Header().Set("Content-Type", "text/javascript")
|
2019-03-13 21:06:35 +00:00
|
|
|
if data, err := Asset(path.Join("htdocs", strings.TrimPrefix(r.URL.Path, "/maatma"))); err != nil {
|
2019-02-24 03:58:43 +00:00
|
|
|
http.NotFound(w, r)
|
|
|
|
} else {
|
|
|
|
w.Write(data)
|
|
|
|
}
|
2018-02-20 12:49:03 +00:00
|
|
|
})
|
2019-03-13 21:06:35 +00:00
|
|
|
Router().GET("/maatma/views/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
2019-02-24 03:58:43 +00:00
|
|
|
w.Header().Set("Content-Type", "text/html")
|
2019-03-13 21:06:35 +00:00
|
|
|
if data, err := Asset(path.Join("htdocs", strings.TrimPrefix(r.URL.Path, "/maatma"))); err != nil {
|
2019-02-24 03:58:43 +00:00
|
|
|
http.NotFound(w, r)
|
|
|
|
} else {
|
|
|
|
w.Write(data)
|
|
|
|
}
|
2018-02-20 12:49:03 +00:00
|
|
|
})
|
|
|
|
}
|