summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
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)
+ })
+ }
+}