aboutsummaryrefslogtreecommitdiff
path: root/controllers/domain/domain.go
diff options
context:
space:
mode:
Diffstat (limited to 'controllers/domain/domain.go')
-rw-r--r--controllers/domain/domain.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/controllers/domain/domain.go b/controllers/domain/domain.go
new file mode 100644
index 0000000..1260e3d
--- /dev/null
+++ b/controllers/domain/domain.go
@@ -0,0 +1,46 @@
+package domain
+
+import (
+ domainService "dove/services/domain"
+ "dove/utils/meta"
+ "dove/utils/shortcuts"
+
+ "github.com/gofiber/fiber/v2"
+)
+
+func CreateDomain(context *fiber.Ctx) error {
+ body, parseError := meta.Body[domainService.CreateDomainRequest](context)
+ if parseError != nil {
+ return shortcuts.BadRequestError(context, parseError)
+ }
+
+ serviceError := domainService.CreateDomain(body)
+ if serviceError != nil {
+ return shortcuts.HandleError(context, serviceError)
+ }
+
+ return shortcuts.Redirect(context, "domains.index")
+}
+
+func CreateTLD(context *fiber.Ctx) error {
+ body, parseError := meta.Body[domainService.CreateTLDRequest](context)
+ if parseError != nil {
+ return shortcuts.BadRequestError(context, parseError)
+ }
+
+ serviceError := domainService.CreateTLD(body)
+ if serviceError != nil {
+ return shortcuts.HandleError(context, serviceError)
+ }
+
+ return shortcuts.Redirect(context, "domains.index")
+}
+
+func DeleteTLD(context *fiber.Ctx) error {
+ serviceError := domainService.DeleteTLD(meta.Request(context).Param("name"))
+ if serviceError != nil {
+ return shortcuts.HandleError(context, serviceError)
+ }
+
+ return shortcuts.Redirect(context, "domains.index")
+} \ No newline at end of file