Created
February 28, 2019 09:52
-
-
Save cflynn07/11ad6fed3cd0666f706abf04884ee31b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package handlers | |
import ( | |
"html/template" | |
"io/ioutil" | |
"log" | |
"net/http" | |
) | |
// HomeHandler / route handler | |
func HomeHandler(w http.ResponseWriter, r *http.Request) { | |
homeVars := struct { | |
Title string | |
}{ | |
Title: "Home", | |
} | |
templateLayout, err := ioutil.ReadFile("../templates/layout.html") | |
if err != nil { | |
log.Fatal(err) | |
} | |
templateHome, err := ioutil.ReadFile("../templates/home.html") | |
if err != nil { | |
log.Fatal(err) | |
} | |
t := template.New("") | |
t.Parse(string(templateLayout)) | |
t.Parse(string(templateHome)) | |
err = t.ExecuteTemplate(w, "layout", homeVars) | |
} | |
// AboutHandler /about route handler | |
func AboutHandler(w http.ResponseWriter, r *http.Request) { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment