Backend changes for frontend changes
This commit is contained in:
6
main.go
6
main.go
@@ -11,6 +11,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -62,15 +63,16 @@ func setupApi(r *mux.Router) {
|
|||||||
func setupFrontend(r *mux.Router) {
|
func setupFrontend(r *mux.Router) {
|
||||||
r.HandleFunc("/article/{article}", server.Article).Methods(http.MethodGet)
|
r.HandleFunc("/article/{article}", server.Article).Methods(http.MethodGet)
|
||||||
|
|
||||||
r.PathPrefix("/sass/").HandlerFunc(server.ServePath)
|
r.PathPrefix("/css/").HandlerFunc(server.ServePath)
|
||||||
r.PathPrefix("/img/").HandlerFunc(server.ServePath)
|
r.PathPrefix("/img/").HandlerFunc(server.ServePath)
|
||||||
r.PathPrefix("/js/").HandlerFunc(server.ServePath)
|
r.PathPrefix("/js/").HandlerFunc(server.ServePath)
|
||||||
|
r.PathPrefix("/html/").HandlerFunc(server.ServePath)
|
||||||
|
|
||||||
landingpage := template.Must(template.ParseFiles(filepath.Join(config.FrontendDir, "html", "landingpage.gohtml")))
|
landingpage := template.Must(template.ParseFiles(filepath.Join(config.FrontendDir, "html", "landingpage.gohtml")))
|
||||||
r.Path("/").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
r.Path("/").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
landingpage.Execute(w, struct {
|
landingpage.Execute(w, struct {
|
||||||
BasePath string
|
BasePath string
|
||||||
}{BasePath: config.Address + path.Join("/", config.SubPath) + "/"})
|
}{BasePath: config.Address + strings.TrimSuffix(path.Join("/", config.SubPath), "/") + "/"})
|
||||||
})
|
})
|
||||||
|
|
||||||
r.NotFoundHandler = http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
r.NotFoundHandler = http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|||||||
Reference in New Issue
Block a user