Implemented subpath support
This commit is contained in:
7
main.go
7
main.go
@@ -7,6 +7,7 @@ import (
|
||||
"TheAdversary/server"
|
||||
"fmt"
|
||||
"github.com/gorilla/mux"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
)
|
||||
@@ -24,7 +25,7 @@ func main() {
|
||||
}
|
||||
database.SetGlobDB(db)
|
||||
|
||||
if err := http.ListenAndServe(fmt.Sprintf(":%s", config.ServerPort), r); err != nil {
|
||||
if err := http.ListenAndServe(fmt.Sprintf("%s:%s", config.ServerURL, config.ServerPort), r); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
@@ -52,9 +53,11 @@ func setupFrontend(r *mux.Router) {
|
||||
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 r.URL.Path == "/" {
|
||||
http.ServeFile(w, r, filepath.Join(config.FrontendDir, "html", "landingpage.html"))
|
||||
landingpage.Execute(w, config.PageBase)
|
||||
} else {
|
||||
server.Error404(w, r)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user