Fixing more stuff

This commit is contained in:
2022-02-06 18:27:30 +01:00
parent 8bc01e0984
commit e582a75d9e
13 changed files with 56 additions and 38 deletions

11
main.go
View File

@@ -62,18 +62,19 @@ func setupApi(r *mux.Router) {
func setupFrontend(r *mux.Router) {
r.HandleFunc("/article/{article}", server.Article).Methods(http.MethodGet)
r.HandleFunc("/assets/{asset}", server.Assets).Methods(http.MethodGet)
r.PathPrefix("/css/").HandlerFunc(server.ServePath)
r.PathPrefix("/img/").HandlerFunc(server.ServePath)
r.PathPrefix("/js/").HandlerFunc(server.ServePath)
r.PathPrefix("/html/").HandlerFunc(server.ServePath)
r.PathPrefix("/css/").HandlerFunc(server.ServePath).Methods(http.MethodGet)
r.PathPrefix("/img/").HandlerFunc(server.ServePath).Methods(http.MethodGet)
r.PathPrefix("/js/").HandlerFunc(server.ServePath).Methods(http.MethodGet)
r.PathPrefix("/html/").HandlerFunc(server.ServePath).Methods(http.MethodGet)
landingpage := template.Must(template.ParseFiles(filepath.Join(config.FrontendDir, "html", "landingpage.gohtml")))
r.Path("/").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
landingpage.Execute(w, struct {
BasePath string
}{BasePath: config.Address + strings.TrimSuffix(path.Join("/", config.SubPath), "/") + "/"})
})
}).Methods(http.MethodGet)
r.NotFoundHandler = http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
server.Error404(w, r)