Skip to content

Instantly share code, notes, and snippets.

@L04DB4L4NC3R
Last active August 18, 2019 02:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save L04DB4L4NC3R/6b11fd21e00089498afb7564b12f78ab to your computer and use it in GitHub Desktop.
Save L04DB4L4NC3R/6b11fd21e00089498afb7564b12f78ab to your computer and use it in GitHub Desktop.
Examinaar 2
package controller
import (
"html/template"
)
type Host struct {
temp \*template.Template
}
func (h Host) RegisterRoutes() {
http.HandleFunc("/host", h.servepage)
http.HandleFunc("/host/session/delete", h.removeSession)
}
// main function
func main() {
// handle requests to static files
http.Handle("/img/", http.FileServer(http.Dir("public")))
http.Handle("/js/", http.FileServer(http.Dir("public")))
http.Handle("/css/", http.FileServer(http.Dir("public")))
http.Handle("/vendor/", http.FileServer(http.Dir("public")))
controller.Startup(populateTemplates())
log.Fatal(http.ListenAndServe(":3000", nil))
}
package controller
import "html/template"
var user User
func Startup(t \*template.Template) {
host.temp = t
host.RegisterRoutes()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment