These are lessons I've learned from developing a web app using the Go programming language.
One of the functions I've used often when developing Django apps is the STATIC_PATH variable. I was able to implement something similar in my Go web app.
import (
"github.com/gorilla/mux"
)
var router *mux.Router
func init() {
router = mux.NewRouter()
router.HandleFunc("/static/{path:.*}", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, r.URL.Path[1:])
}).Name("static")
}
The above routing code defines a "static" named URL. The named URL parses the request URL to find out what resource is being requested and serves the file from the filesystem.
Comments
comments powered by Disqus