Serving static content with a root URL with the Gorilla toolkit

I think you might be looking for PathPrefix

func main() {
    r := mux.NewRouter()
    r.HandleFunc("/search/{searchTerm}", Search)
    r.HandleFunc("/load/{dataId}", Load)
    r.PathPrefix("https://stackoverflow.com/").Handler(http.FileServer(http.Dir("./static/")))
    http.ListenAndServe(":8100", r)
}

Leave a Comment