I have this code as my myApp.go:
package fastaticapp
import (
"html/template"
"log"
"net/http"
)
func init() {
http.HandleFunc("/", rootHandler)
}
func rootHandler(w http.ResponseWriter, r *http.Request) {
http.Handle("/css/", http.StripPrefix("/css/", http.FileServer(http.Dir("css"))))
if r.URL.Path != "/" {
errorHandler(w, r, http.StatusNotFound, "")
return
}
page := template.Must(template.ParseFiles(
"static/_base.html",
"static/index.html",
))
if err := page.Execute(w, nil); err != nil {
errorHandler(w, r, http.StatusInternalServerError, err.Error())
return
}
}
And the direcotry Layout looks like this:
webapp/
myApp/
server.go
static/
index.html
_base.html
img/
css/
main.css
I am using template package with Must function. running the dev server, the HTML page gets rendered by the browser and using developer tools I can see the html contents. The problem is main.css file within the css folder does not appear to be properly handled by the server. Any thought on this would be highly appreciated.