如何有条件地同时重定向和使用资产提供HTML

Problem

When I want to serve static HTML, the assets (CSS, JavaScript) MIME-type is also text/html, which leads to an error.

Approach

Inside ./assets/ is an index.html, CSS and JavaScript files.

const rootHtml = "./assets/index.html"

func main() {
    http.HandleFunc("/", root)

    log.Fatal(http.ListenAndServe(":3000", nil))
}

func root(w http.ResponseWriter, r *http.Request) {
    if false {
        http.Redirect(w, r, "/other-route/, http.StatusTemporaryRedirect)
    } else {
        http.ServeFile(w, r, rootHtml) // This should handle the index.html and all other resources
    }
}

Assets directory:

assets/
|-- js/
|-- css/
|-- index.html