title: Go HTTP Server: Handling Routes with Map
body: <p>I have a <code>map</code> in Go with routes (e.g. <code>/static/stylesheets/main.css</code>) as keys and the corresponding code as the value (effectively, a giant string). I was just wondering, is there an easy way in Go by which I can create an HTTP server, which always check an incoming request against the <code>map</code> and renders the value associated with the matched key, if the key exists?</p>
  
  <p>So far, I have...</p>
  
  <pre class="lang-js prettyprint-override"><code>func main() {
      var m = generateMap()
      http.handleFunc("/", renderContent);
  }
  
  func renderContent(w http.ResponseWriter, r *http.Request) {
      io.WriteString(w, m[path]); 
  }
  </code></pre>
  
  <p>I know this code is far from done, but hopefully it clarifies my objective. How would I pass in the <code>path</code> and <code>m</code> into <code>renderContent</code> as well as how do I have <code>handleFunc</code> actually handle regexes (essentially, any path)?</p>