Finished subpath implementation
This commit is contained in:
6
main.go
6
main.go
@@ -11,7 +11,6 @@ import (
|
||||
"net/http"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -56,16 +55,13 @@ func setupApi(r *mux.Router) {
|
||||
func setupFrontend(r *mux.Router) {
|
||||
r.HandleFunc("/article/{article}", server.Article).Methods(http.MethodGet)
|
||||
|
||||
r.HandleFunc("/favicon.ico", func(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, filepath.Join(config.FrontendDir, "img", "logodark.svg"))
|
||||
})
|
||||
r.PathPrefix("/sass/").HandlerFunc(server.ServePath)
|
||||
r.PathPrefix("/img/").HandlerFunc(server.ServePath)
|
||||
|
||||
landingpage := template.Must(template.ParseFiles(filepath.Join(config.FrontendDir, "html", "landingpage.gohtml")))
|
||||
|
||||
r.PathPrefix("/").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if strings.TrimPrefix(r.URL.Path, path.Dir(config.Prefix)) == "/" {
|
||||
if path.Join(config.Prefix)+"/" == r.URL.Path {
|
||||
landingpage.Execute(w, config.PageBase)
|
||||
} else {
|
||||
server.Error404(w, r)
|
||||
|
||||
Reference in New Issue
Block a user