From fd3eab3ad60b0bb27514a4d8060543da90909cc9 Mon Sep 17 00:00:00 2001 From: kevin olson Date: Wed, 5 Oct 2022 11:29:45 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20adding=20create=20route?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- route/route.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/route/route.go b/route/route.go index 7c40a1b..21c887b 100644 --- a/route/route.go +++ b/route/route.go @@ -12,6 +12,7 @@ import ( type ApiResourceStruct struct { Index func(c *fiber.Ctx) error + Create func(c *fiber.Ctx) error Show func(c *fiber.Ctx, value any) error Update func(c *fiber.Ctx, value any) error Delete func(c *fiber.Ctx, value any) error @@ -61,11 +62,13 @@ func ApiResource(app *fiber.App, n string, _model any, _resources ApiResourceStr if middleware != nil { mid := middleware.(fiber.Handler) app.Get("/"+n, mid, resources.Index).Name(n + " Index") + app.Post("/"+n, mid, resources.Create).Name(n + " Create") app.Get("/"+n+"/:id", mid, bindShow).Name(n + " Show") app.Put("/"+n+"/:id", mid, bindUpdate).Name(n + " Update") app.Delete("/"+n+"/:id", mid, bindDelete).Name(n + " Delete") } else { app.Get("/"+n, resources.Index).Name(n + " Index") + app.Post("/"+n, resources.Create).Name(n + " Create") app.Get("/"+n+"/:id", bindShow).Name(n + " Show") app.Put("/"+n+"/:id", bindUpdate).Name(n + " Update") app.Delete("/"+n+"/:id", bindDelete).Name(n + " Delete")