Elektromarket/initializers/initializers.go

35 lines
668 B
Go

package initializers
import (
"net/http"
. "Elektromarket/models"
)
func initializePages() {
Pages = make(map[string]Page)
Pages["index"] = Page{Path: "/", Template: "templates/index.html", Data: map[string]interface{}{"test": '1'}}
}
func initializeData() {
Categories = []Category {
{1, "Laptopy"},
{2, "Komputery"},
{3, "Smartfony"},
{4, "Smartwache"},
{5, "Monitory"},
{6, "Drukarki"},
{7, "Myszki"},
{8, "Klawiatury"},
{9, "Akcesoria"},
}
}
func Initialize() {
initializePages()
initializeData()
for k := range Pages {
http.HandleFunc(Pages[k].Path, Pages[k].HandlePage)
}
http.ListenAndServe(":8000", nil)
}