aboutsummaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorMikunoNaka <bokuwakanojogahoshii@yahoo.com>2021-05-02 19:50:39 +0530
committerMikunoNaka <bokuwakanojogahoshii@yahoo.com>2021-05-02 19:50:39 +0530
commitc7768652ed63e408e19c7e68d2ab8e78c70da94f (patch)
tree567f8430af60b364525a7404ddc181bac00e4113 /server
parent17ea30faae3c3b0ab1d58bbeb6c1a6a404639817 (diff)
defined (working) api route to register a new client/person
Diffstat (limited to 'server')
-rw-r--r--server/database/people.go13
-rw-r--r--server/main.go1
2 files changed, 1 insertions, 13 deletions
diff --git a/server/database/people.go b/server/database/people.go
index 0ff3acb..6083af4 100644
--- a/server/database/people.go
+++ b/server/database/people.go
@@ -12,7 +12,6 @@ package database
import (
_ "github.com/mattn/go-sqlite3"
- "fmt"
)
type Person struct {
@@ -40,18 +39,6 @@ func GetAllPeople() []Person {
}
func RegisterPerson(person Person) bool {
- personNames, _ := myDatabase.Query("SELECT Name FROM People")
-
- // check if already exists
- // probs shouldnt make it
- // make front end handle it
- for personNames.Next() {
- var rPerson string
- if rPerson == person.Name {
- fmt.Println(person.Name, "already exists")
- return false
- }
- }
register_person, _ := myDatabase.Prepare(
`INSERT INTO People
diff --git a/server/main.go b/server/main.go
index 1740ac6..49d8c45 100644
--- a/server/main.go
+++ b/server/main.go
@@ -41,6 +41,7 @@ func main() {
// people API routes
people.GET("/", getAllPeople)
+ people.POST("/", registerPerson)
myRouter.Run(":8080")
}