Last active
February 12, 2017 16:24
-
-
Save zendrulat/b75ff18c30aea89da0ffb714e69e1066 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 main | |
import ( | |
"log" | |
"net/http" | |
"html/template" | |
"github.com/gorilla/mux" | |
) | |
var tpl *template.Template | |
func init() { | |
tpl = template.Must(template.ParseGlob("templates/*.gohtml")) | |
} | |
func main() { | |
router := mux.NewRouter().StrictSlash(true) | |
router.HandleFunc("/", Index) | |
router.HandleFunc("/about", about) | |
router.HandleFunc("/links", links) | |
log.Fatal(http.ListenAndServe(":8080", router)) | |
} | |
func Index(w http.ResponseWriter, r *http.Request) { | |
tpl.ExecuteTemplate(w, "index.gohtml", nil) | |
} | |
func about(w http.ResponseWriter, r *http.Request) { | |
tpl.ExecuteTemplate(w, "index.gohtml", nil) | |
} | |
func links(w http.ResponseWriter, r *http.Request) { | |
tpl.ExecuteTemplate(w, "index.gohtml", nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment