Browse Source

Now builds, added db to .gitignore

main
Unbewohnte 3 years ago
parent
commit
b1fe38782a
  1. 1
      .gitignore
  2. 24
      dbHandle/handle.go
  3. 2
      go.sum
  4. 1
      main.go

1
.gitignore vendored

@ -1,3 +1,4 @@
logs.log logs.log
database.db
crud-api crud-api
crud-api.exe crud-api.exe

24
dbHandle/handle.go

@ -7,13 +7,21 @@ import (
_ "github.com/mattn/go-sqlite3" _ "github.com/mattn/go-sqlite3"
) )
func (db *DB) GetEverything() ([]*randomdata.RandomData, error) func (db *DB) GetEverything() ([]*randomdata.RandomData, error) {
return nil, nil
}
func (db *DB) GetSpecific() (*randomdata.RandomData, error) func (db *DB) GetSpecific() (*randomdata.RandomData, error) {
return nil, nil
}
func (db *DB) DeleteSpecific() error func (db *DB) DeleteSpecific() error {
return nil
}
func (db *DB) PatchSpecific() error func (db *DB) PatchSpecific() error {
return nil
}
func (db *DB) Create(rd randomdata.RandomData) error { func (db *DB) Create(rd randomdata.RandomData) error {
_, err := db.Exec("INSERT INTO randomdata (title, text) VALUES (?, ?)", rd.Title, rd.Text) _, err := db.Exec("INSERT INTO randomdata (title, text) VALUES (?, ?)", rd.Title, rd.Text)
@ -24,6 +32,10 @@ func (db *DB) Create(rd randomdata.RandomData) error {
return nil return nil
} }
func (db *DB) HandleSpecificWeb(w http.ResponseWriter, r *http.Request) func (db *DB) HandleSpecificWeb(w http.ResponseWriter, r *http.Request) {
}
func (db *DB) HandleGlobalWeb(w http.ResponseWriter, r *http.Request) func (db *DB) HandleGlobalWeb(w http.ResponseWriter, r *http.Request) {
}

2
go.sum

@ -0,0 +1,2 @@
github.com/mattn/go-sqlite3 v1.14.8 h1:gDp86IdQsN/xWjIEmr9MF6o9mpksUgh0fu+9ByFxzIU=
github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=

1
main.go

@ -32,6 +32,7 @@ func main() {
if err != nil { if err != nil {
log.Fatalf("error setting up a database: %s", err) log.Fatalf("error setting up a database: %s", err)
} }
log.Println("Created db")
mux := http.NewServeMux() mux := http.NewServeMux()
mux.HandleFunc("/", helpPage) mux.HandleFunc("/", helpPage)

Loading…
Cancel
Save