diff --git a/src/main/java/com/hithomelabs/CFTunnels/Models/Ingress.java b/src/main/java/com/hithomelabs/CFTunnels/Models/Ingress.java index 005a02b..05d22ab 100644 --- a/src/main/java/com/hithomelabs/CFTunnels/Models/Ingress.java +++ b/src/main/java/com/hithomelabs/CFTunnels/Models/Ingress.java @@ -8,19 +8,88 @@ import lombok.Setter; import java.util.List; import java.util.Map; +/** + * Model representing an ingress rule for a Cloudflare Tunnel. + * + *

Ingress rules define how incoming requests should be routed through + * the tunnel to your internal services. Each rule specifies:

+ * + * + *

Example JSON:

+ *
+ * {
+ *   "hostname": "api.example.com",
+ *   "service": "http://localhost:8080",
+ *   "originRequest": {
+ *     "noTLSVerify": true
+ *   },
+ *   "path": "/api"
+ * }
+ * 
+ * + * @see Cloudflare Ingress Docs + */ @NoArgsConstructor @AllArgsConstructor @Getter @Setter public class Ingress { + /** + * The target service URL. + * + *

Format: {@code protocol://host:port}

+ *

Example: {@code http://localhost:8080}

+ */ private String service; + + /** + * Hostname pattern to match for this ingress rule. + * + *

Can be a full domain (api.example.com) or use wildcards + * (*.example.com) to match subdomains.

+ *

If null, this rule acts as a catch-all.

+ */ private String hostname; + + /** + * Optional settings for requests to the origin server. + * + *

Supported options:

+ * + */ private Map originRequest; + + /** + * Optional path to match before routing. + * + *

Example: "/api" would only route requests with + * paths starting with /api to this service.

+ */ private String path; + /** + * Removes an ingress rule by hostname from a list. + * + *

This utility method finds and removes the first ingress + * matching the given hostname.

+ * + * @param ingressList List of ingress rules to modify + * @param toBeDeleted Hostname of the rule to remove + * @return true if an ingress was removed, false otherwise + */ public static boolean deleteByHostName(List ingressList, String toBeDeleted){ return ingressList.removeIf(ingress -> ingress.getHostname() != null && ingress.getHostname().equals(toBeDeleted)); } -} +} \ No newline at end of file