summaryrefslogtreecommitdiff
path: root/brand/brand_router.go
diff options
context:
space:
mode:
Diffstat (limited to 'brand/brand_router.go')
-rw-r--r--brand/brand_router.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/brand/brand_router.go b/brand/brand_router.go
new file mode 100644
index 0000000..3930931
--- /dev/null
+++ b/brand/brand_router.go
@@ -0,0 +1,26 @@
+package brand
+
+import (
+ "github.com/gin-gonic/gin"
+ "github.com/MikunoNaka/OpenBills-lib/brand"
+ "log"
+ "net/http"
+)
+
+
+func Routes(route *gin.Engine) {
+ b := route.Group("/brand")
+ {
+ b.POST("/", func(ctx *gin.Context) {
+ var x brand.Brand
+ ctx.Bind(&x)
+ err := x.Save()
+ if err != nil {
+ ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
+ }
+
+ log.Println("Added new brand to database: ", x.Name)
+ ctx.JSON(http.StatusOK, nil)
+ })
+ }
+}