getResourceFromPath determines the resource type from the URL path. Parameters: - path: The URL path to analyze. Returns: - Resource: The determined resource type, or empty string if not found.
(path string)
| 74 | // Returns: |
| 75 | // - Resource: The determined resource type, or empty string if not found. |
| 76 | func getResourceFromPath(path string) Resource { |
| 77 | // Remove leading slash and get first path segment |
| 78 | parts := strings.Split(strings.TrimPrefix(path, "/"), "/") |
| 79 | if len(parts) == 0 { |
| 80 | return "" |
| 81 | } |
| 82 | |
| 83 | // Special case for mocked-account |
| 84 | if parts[0] == "mocked-account" { |
| 85 | return ResourceAccounts |
| 86 | } |
| 87 | |
| 88 | // Special case for multi-search |
| 89 | if parts[0] == "multi-search" { |
| 90 | return ResourceSearch |
| 91 | } |
| 92 | |
| 93 | if parts[0] == "refund-transaction" { |
| 94 | return ResourceTransactions |
| 95 | } |
| 96 | |
| 97 | // Check if the path segment maps to a known resource |
| 98 | if resource, ok := pathToResource[parts[0]]; ok { |
| 99 | return resource |
| 100 | } |
| 101 | |
| 102 | return "" |
| 103 | } |
| 104 | |
| 105 | // injectAPIKeyToMetadata modifies the request body to include the API key ID in the meta_data. |
| 106 | // This function reads the request body, adds or updates the meta_data field, and sets the modified |
no outgoing calls