I am working on a simple todo app in go.
I have determined that all the pages except a user's list of todos can safely be a static html page. * Login form * new account form * index page that talks about the todo app
I see no reason currently for these to be go templates.
My question is how (within go, not using something like nginx) can I have a static html set to return at a specific route most efficiently?
For example index.html to be returned at "/"
I know I could do something like:
func GetNewAccount(res http.ResponseWriter, req *http.Request) {
body, _ := ioutil.ReadFile("templates/register.html")
fmt.Fprint(res, string(body))
}
or
var register, _ = string(ioutil.ReadFile("templates/register.html"))
func GetNewAccount(res http.ResponseWriter, req *http.Request) {
fmt.Fprint(res, register)
}
To me these seems like more roundabout ways to do something seemingly simple.