This is the first time that I attempt to write a small blog using Go (Golang). Right now, I have a small website running with only a few pages. My main
contains this.
http.HandleFunc("/about", about)
http.HandleFunc("/contact", contact)
http.HandleFunc("/", homepage)
if err := http.ListenAndServe(":8080", nil); err != nil {
log.Fatalln(err)
}
My first question is: What is this called? I call it mapping URLs to functions, but my Google results haven't been fruitful with those search terms. Is this called "routing"?
Secondly, my goal is to write a small blog app. I want to use a database to save blog posts and other data. However, mapping URLs to functions like I did above doesn't seem right because there is no way to know what the URL should be until someone makes a blog post. I would want the URL to match the blog post title. In addition, there could be hundreds of blog posts, so writing a bunch of http.HandleFunc
s seems unreasonable.
Finally, my question is this: What options are available to solve this obstacle?