package db zu data umbenannt, außerdem db.Open() zu data.OpenDB()
This commit is contained in:
parent
1597d38d34
commit
616df72041
5
main.go
5
main.go
@ -4,7 +4,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"streifling.com/jason/sicherheitsunterweisung/packages/db"
|
"streifling.com/jason/sicherheitsunterweisung/packages/data"
|
||||||
"streifling.com/jason/sicherheitsunterweisung/packages/server"
|
"streifling.com/jason/sicherheitsunterweisung/packages/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ func main() {
|
|||||||
i, j = 1, 1
|
i, j = 1, 1
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
|
|
||||||
db, err := db.Open("sicherheitsunterweisung")
|
db, err := data.OpenDB("sicherheitsunterweisung")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
@ -24,6 +24,7 @@ func main() {
|
|||||||
mux.HandleFunc("/new-briefing/", server.DisplayForm(&i))
|
mux.HandleFunc("/new-briefing/", server.DisplayForm(&i))
|
||||||
mux.HandleFunc("/add-participant/", server.AddParticipant(&i))
|
mux.HandleFunc("/add-participant/", server.AddParticipant(&i))
|
||||||
mux.HandleFunc("/submit-form/", server.SubmitForm(db, &i, &j))
|
mux.HandleFunc("/submit-form/", server.SubmitForm(db, &i, &j))
|
||||||
|
mux.HandleFunc("/generate-uuid/", server.GenerateUUID())
|
||||||
|
|
||||||
log.Fatalln(http.ListenAndServe(":8080", mux))
|
log.Fatalln(http.ListenAndServe(":8080", mux))
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package db
|
package data
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
@ -43,7 +43,7 @@ func reverseOrder(bs *[]types.Briefing) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Open(dbName string) (*DB, error) {
|
func OpenDB(dbName string) (*DB, error) {
|
||||||
var err error
|
var err error
|
||||||
db := new(DB)
|
db := new(DB)
|
||||||
|
|
@ -8,11 +8,11 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"streifling.com/jason/sicherheitsunterweisung/packages/db"
|
"streifling.com/jason/sicherheitsunterweisung/packages/data"
|
||||||
"streifling.com/jason/sicherheitsunterweisung/packages/types"
|
"streifling.com/jason/sicherheitsunterweisung/packages/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func DisplayTable(db *db.DB) http.HandlerFunc {
|
func DisplayTable(db *data.DB) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
bs, err := db.ReadAll()
|
bs, err := db.ReadAll()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -22,7 +22,7 @@ func DisplayTable(db *db.DB) http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func DisplayResults(db *db.DB) http.HandlerFunc {
|
func DisplayResults(db *data.DB) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
bs, err := db.ReadByName(r.PostFormValue("search"))
|
bs, err := db.ReadByName(r.PostFormValue("search"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -45,7 +45,7 @@ func AddParticipant(i *int64) http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func SubmitForm(db *db.DB, i, j *int64) http.HandlerFunc {
|
func SubmitForm(db *data.DB, i, j *int64) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
b := new(types.Briefing)
|
b := new(types.Briefing)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user