diff options
| author | Bobby <[email protected]> | 2026-03-08 17:47:48 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2026-03-08 17:47:48 +0530 |
| commit | f48054e9bc5e4fb36b9aba9126c6ace9c5b1f470 (patch) | |
| tree | 0e993ddab1229ba7efccbb757987addb86effbe3 /controllers | |
| parent | 2d5fb5e2078e92e7ec19582c3954409dd93f89fd (diff) | |
| download | dove-f48054e9bc5e4fb36b9aba9126c6ace9c5b1f470.tar.xz dove-f48054e9bc5e4fb36b9aba9126c6ace9c5b1f470.zip | |
feat(domains): enhance domain management UI with DNS records functionality
- Updated domain detail view to include DNS records management links.
- Added new DNS records creation form with dynamic fields based on record type.
- Implemented backend logic for creating and deleting DNS records.
- Introduced new services and messages for DNS operations.
- Refactored SMTP server initialization to streamline TLS configuration.
- Added email composition and submission utilities for better email handling.
Diffstat (limited to 'controllers')
| -rw-r--r-- | controllers/dns/records.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/controllers/dns/records.go b/controllers/dns/records.go new file mode 100644 index 0000000..d16a6b3 --- /dev/null +++ b/controllers/dns/records.go @@ -0,0 +1,44 @@ +package dns + +import ( + "fmt" + "strconv" + + dnsService "dove/services/dns" + "dove/utils/meta" + "dove/utils/shortcuts" + + "github.com/gofiber/fiber/v2" +) + +func CreateRecord(context *fiber.Ctx) error { + body, parseError := meta.Body[dnsService.CreateRecordRequest](context) + if parseError != nil { + return shortcuts.BadRequestError(context, parseError) + } + + serviceError := dnsService.CreateRecord(body) + if serviceError != nil { + return shortcuts.HandleError(context, serviceError) + } + + return shortcuts.RedirectToPath(context, fmt.Sprintf("/domains/manage/%d", body.DomainID)) +} + +func DeleteRecord(context *fiber.Ctx) error { + recordID, parseError := strconv.ParseUint(meta.Request(context).Param("id"), 10, 64) + if parseError != nil { + return shortcuts.BadRequestError(context, parseError) + } + + recordType := meta.Request(context).Param("type") + + serviceError := dnsService.DeleteRecord(recordType, uint(recordID)) + if serviceError != nil { + return shortcuts.HandleError(context, serviceError) + } + + domainID := meta.Request(context).Query("domain_id") + + return shortcuts.RedirectToPath(context, fmt.Sprintf("/domains/manage/%s", domainID)) +} |
