A basic, barebones web app, intented to be used as a starting point for developing an Isomorphic Go application.

index.go 498B

12345678910111213141516171819202122
  1. package handlers
  2. import (
  3. "html/template"
  4. "log"
  5. "net/http"
  6. "os"
  7. )
  8. // Template rendering function
  9. func RenderTemplate(w http.ResponseWriter, templateFile string, templateData interface{}) {
  10. t, err := template.ParseFiles(templateFile)
  11. if err != nil {
  12. log.Fatal("Error encountered while parsing the template: ", err)
  13. }
  14. t.Execute(w, templateData)
  15. }
  16. func IndexHandler(w http.ResponseWriter, r *http.Request) {
  17. RenderTemplate(w, os.Getenv("ISOGO_APP_ROOT")+"/templates/index.tmpl", nil)
  18. }