diff --git a/admin/handlers.go b/admin/handlers.go index f0cbeb1..9d5b026 100644 --- a/admin/handlers.go +++ b/admin/handlers.go @@ -71,7 +71,15 @@ func PostApiUpdate(c *fiber.Ctx) error { return c.RedirectBack("/admin/table/", 303) } -func PutApiInsert(c *fiber.Ctx) error { +func GetPageInsert(c *fiber.Ctx) error { + table := c.Params("table") + + // NOTE: need to get a blank json for the table schema and use that to populate the template OR have a simple get that does it. Probably the former. + + return c.Render("admin/table/new", fiber.Map{ "Table": table }) +} + +func PostApiInsert(c *fiber.Ctx) error { return c.JSON(fiber.Map{}) } @@ -93,10 +101,13 @@ func Setup(app *fiber.App) { app.Get("/api/admin/table/:table/", GetApiSelectAll) app.Get("/admin/table/:table/", GetPageSelectAll) + app.Get("/admin/new/table/:table/", GetPageInsert) + app.Post("/api/admin/new/table/:table/", PostApiInsert) + app.Get("/api/admin/table/:table/:id/", GetApiSelectOne) app.Get("/admin/table/:table/:id/", GetPageSelectOne) app.Post("/api/admin/table/:table/:id/", PostApiUpdate) - app.Put("/api/admin/table/:table/:id/", PutApiInsert) + app.Delete("/api/admin/table/:table/:id/", DeleteApi) } diff --git a/common/web.go b/common/web.go index 9e2622e..94adb91 100644 --- a/common/web.go +++ b/common/web.go @@ -12,7 +12,7 @@ import ( func Page(path string) (func(c *fiber.Ctx) error) { return func (c *fiber.Ctx) error { - return c.Render("stream", fiber.Map{}) + return c.Render(path, fiber.Map{}) } }