static file handler to include bootstrap stylesheets

This commit is contained in:
Johannes 2022-09-21 15:40:16 +02:00
parent c737818ce4
commit 16e8cf9cd7
7 changed files with 27 additions and 1 deletions

View file

@ -7,11 +7,11 @@ import (
"log"
"log/syslog"
"net/http"
"os"
"officeHours/config"
"officeHours/controllers"
"officeHours/repositories"
"officeHours/sqldb"
"os"
)
func main() {
@ -35,6 +35,9 @@ func main() {
log.Fatalf("%s: %s", "Reading JSON config file into config structure", err)
}
// serve static files
staticHandler := http.FileServer(http.Dir("./static"))
db := sqldb.Connect(conf)
// Create repos
roomRepo := repositories.NewRoomRepo(db)
@ -50,6 +53,7 @@ func main() {
http.HandleFunc("/confirmRequest", h.ConfirmRequestHandler)
http.HandleFunc("/deleteOfficeHour", h.DeleteOfficeHourHandler)
http.HandleFunc("/", h.RootHandler)
http.Handle("/static/", http.StripPrefix("/static/", staticHandler))
err = http.ListenAndServe(fmt.Sprintf("%s:%d", conf.Server.ListenAddress, conf.Server.ListenPort), nil)
log.Println(err.Error())