summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-09-25 15:29:13 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-09-25 15:29:13 +0530
commit2326633e76aaf9c5e733e08045c0a26b81f9f4e6 (patch)
tree270fbbb8a71d0dd0c7281fb6becc0d67f1368590 /client
parent82d9a0f82bc776bf5b026f64c5bf63b89719906a (diff)
Added endpoints to add and delete data
Diffstat (limited to 'client')
-rw-r--r--client/client_router.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/client/client_router.go b/client/client_router.go
new file mode 100644
index 0000000..8b16f2e
--- /dev/null
+++ b/client/client_router.go
@@ -0,0 +1,25 @@
+package client
+
+import (
+ "github.com/gin-gonic/gin"
+ "github.com/MikunoNaka/OpenBills-lib/client"
+ "log"
+ "net/http"
+)
+
+func Routes(route *gin.Engine) {
+ c := route.Group("/client")
+ {
+ c.POST("/", func(ctx *gin.Context) {
+ var x client.Client
+ ctx.Bind(&x)
+ err := x.Save()
+ if err != nil {
+ ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
+ }
+
+ log.Println("Added new client to database: ", x.Name)
+ ctx.JSON(http.StatusOK, nil)
+ })
+ }
+}