aboutsummaryrefslogtreecommitdiff
path: root/utils/urls/path.go
diff options
context:
space:
mode:
Diffstat (limited to 'utils/urls/path.go')
-rw-r--r--utils/urls/path.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/utils/urls/path.go b/utils/urls/path.go
new file mode 100644
index 0000000..b865676
--- /dev/null
+++ b/utils/urls/path.go
@@ -0,0 +1,37 @@
+package urls
+
+import (
+ "dove/enums"
+
+ "github.com/gofiber/fiber/v2"
+)
+
+func Path(method enums.HTTPMethod, path string, handler fiber.Handler, name string) {
+ registry.Mutex.Lock()
+ defer registry.Mutex.Unlock()
+
+ namespace := registry.CurrentNamespace
+ fullName := resolveFullName(namespace, name)
+ fullPath := resolveFullPath(namespace, path)
+
+ registry.Routes[fullName] = registeredRoute{
+ Method: method,
+ Path: path,
+ Handler: handler,
+ Namespace: namespace,
+ Name: name,
+ FullPath: fullPath,
+ }
+}
+
+func GetFullPath(routeName string) (string, bool) {
+ registry.Mutex.Lock()
+ defer registry.Mutex.Unlock()
+
+ route, exists := registry.Routes[routeName]
+ if !exists {
+ return "", false
+ }
+
+ return route.FullPath, true
+}