37 lines
540 B
Go
37 lines
540 B
Go
package models
|
|
|
|
import (
|
|
"net/http"
|
|
"html/template"
|
|
)
|
|
|
|
type Page struct {
|
|
Path string
|
|
Template string
|
|
Data map[string]interface{}
|
|
}
|
|
|
|
func (p Page) HandlePage(w http.ResponseWriter, r *http.Request) {
|
|
t, _ := template.ParseFiles(p.Template)
|
|
t.Execute(w, p.Data)
|
|
}
|
|
|
|
type Category struct {
|
|
Id uint
|
|
Name string
|
|
}
|
|
|
|
type Product struct {
|
|
Id uint
|
|
Category Category
|
|
Name string
|
|
Description string
|
|
ImgUrl string
|
|
Quantity uint
|
|
Price uint
|
|
}
|
|
|
|
var Pages map[string]Page
|
|
var Categories []Category
|
|
var Products []Product
|