forked from Hithomelabs/CFTunnels
Hithomelabs/CFTunnels#114: Add JavaDoc to Ingress model
This commit is contained in:
parent
df7ea9a2df
commit
4197e645cd
@ -8,19 +8,88 @@ import lombok.Setter;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model representing an ingress rule for a Cloudflare Tunnel.
|
||||||
|
*
|
||||||
|
* <p>Ingress rules define how incoming requests should be routed through
|
||||||
|
* the tunnel to your internal services. Each rule specifies:</p>
|
||||||
|
* <ul>
|
||||||
|
* <li>{@link #hostname} - The domain/subdomain to match</li>
|
||||||
|
* <li>{@link #service} - The internal service URL</li>
|
||||||
|
* <li>{@link #originRequest} - Optional settings for origin requests</li>
|
||||||
|
* <li>{@link #path} - Optional path prefix to match</li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* <p><b>Example JSON:</b></p>
|
||||||
|
* <pre>
|
||||||
|
* {
|
||||||
|
* "hostname": "api.example.com",
|
||||||
|
* "service": "http://localhost:8080",
|
||||||
|
* "originRequest": {
|
||||||
|
* "noTLSVerify": true
|
||||||
|
* },
|
||||||
|
* "path": "/api"
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @see <a href="https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/routing/ingress/">Cloudflare Ingress Docs</a>
|
||||||
|
*/
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class Ingress {
|
public class Ingress {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The target service URL.
|
||||||
|
*
|
||||||
|
* <p>Format: {@code protocol://host:port}</p>
|
||||||
|
* <p>Example: {@code http://localhost:8080}</p>
|
||||||
|
*/
|
||||||
private String service;
|
private String service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hostname pattern to match for this ingress rule.
|
||||||
|
*
|
||||||
|
* <p>Can be a full domain (api.example.com) or use wildcards
|
||||||
|
* (*.example.com) to match subdomains.</p>
|
||||||
|
* <p>If null, this rule acts as a catch-all.</p>
|
||||||
|
*/
|
||||||
private String hostname;
|
private String hostname;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional settings for requests to the origin server.
|
||||||
|
*
|
||||||
|
* <p>Supported options:</p>
|
||||||
|
* <ul>
|
||||||
|
* <li>noTLSVerify - Skip TLS verification</li>
|
||||||
|
* <li>connectTimeout - Connection timeout in seconds</li>
|
||||||
|
* <li>tlsTimeout - TLS handshake timeout</li>
|
||||||
|
* <li>httpHostHeader - Host header to send</li>
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
private Map<String, Object> originRequest;
|
private Map<String, Object> originRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional path to match before routing.
|
||||||
|
*
|
||||||
|
* <p>Example: "/api" would only route requests with
|
||||||
|
* paths starting with /api to this service.</p>
|
||||||
|
*/
|
||||||
private String path;
|
private String path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes an ingress rule by hostname from a list.
|
||||||
|
*
|
||||||
|
* <p>This utility method finds and removes the first ingress
|
||||||
|
* matching the given hostname.</p>
|
||||||
|
*
|
||||||
|
* @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<Ingress> ingressList, String toBeDeleted){
|
public static boolean deleteByHostName(List<Ingress> ingressList, String toBeDeleted){
|
||||||
return ingressList.removeIf(ingress -> ingress.getHostname() != null && ingress.getHostname().equals(toBeDeleted));
|
return ingressList.removeIf(ingress -> ingress.getHostname() != null && ingress.getHostname().equals(toBeDeleted));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user