Skip to content

Commit

Permalink
✨ adding create route
Browse files Browse the repository at this point in the history
  • Loading branch information
acidjazz committed Oct 5, 2022
1 parent 2a7f1d7 commit fd3eab3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions route/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit fd3eab3

Please sign in to comment.