moved to gorm
This commit is contained in:
parent
66884c64bb
commit
a074f264df
30 changed files with 247 additions and 1040 deletions
|
|
@ -5,12 +5,12 @@ import (
|
|||
"html/template"
|
||||
"net/http"
|
||||
|
||||
"github.com/Bronku/iroon/store"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
tmpl map[string]*template.Template
|
||||
s *store.Store
|
||||
db *gorm.DB
|
||||
routes map[string]route
|
||||
http.Handler
|
||||
}
|
||||
|
|
@ -21,9 +21,6 @@ type route struct {
|
|||
templateEntry string
|
||||
}
|
||||
|
||||
func (h *Server) Close() {
|
||||
}
|
||||
|
||||
//go:embed static/*
|
||||
var static embed.FS
|
||||
|
||||
|
|
@ -42,8 +39,10 @@ func (h *Server) loadHandler() {
|
|||
h.Handler = mux
|
||||
}
|
||||
|
||||
func New(store *store.Store) *Server {
|
||||
var server Server
|
||||
func New(db *gorm.DB) *Server {
|
||||
server := Server{
|
||||
db: db,
|
||||
}
|
||||
|
||||
server.routes = map[string]route{
|
||||
"GET /order/": {server.order, "order", "layout"},
|
||||
|
|
@ -56,7 +55,7 @@ func New(store *store.Store) *Server {
|
|||
}
|
||||
|
||||
server.loadTemplates()
|
||||
server.s = store
|
||||
|
||||
server.loadHandler()
|
||||
|
||||
return &server
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue