API Endpoints for stefanprodan/timoni
Documentation: Defined Routes in Timoni
Overview
In Timoni, routes are typically defined in the context of HTTP Ingress resources. The routing mechanism allows incoming requests to be forwarded to specific backends based on the URL path, and these paths can be specified with different types of matching rules.
Defining Routes
Route Types
The routes in Timoni are determined using the HTTPIngressPath
definition which associates a path with a backend service. There are defined path types that determine how the paths are matched:
- Exact Match: This type matches the URL path exactly, ensuring case sensitivity.
#PathTypeExact: #PathType & "Exact"
- Prefix Match: This matches the incoming URL path with a specified prefix. The matching is done on a path element-by-element basis.
#PathTypePrefix: #PathType & "Prefix"
- Implementation Specific: The interpretation of this matching type is contingent on the specific IngressClass.
#PathTypeImplementationSpecific: #PathType & "ImplementationSpecific"
HTTP Ingress Path Structure
The HTTPIngressPath
struct defines how a path is set up in relation to its backend. The definition requires paths to start with a /
and it applies to path types either Exact
or Prefix
.
#HTTPIngressPath: {
// path is matched against the path of an incoming request.
path?: string @go(Path) @protobuf(1,bytes,opt)
}
Routing via Ingress Rules
The IngressRule
struct encompasses rules that map paths to backend services under specified hosts. For each incoming request, the host match is evaluated first, followed by the corresponding backend.
#IngressRule: {
// host is the qualified domain name for matching incoming requests.
host: string
// Define the HTTP rules that will be applied under this host.
http?: #HTTPIngressRuleValue
}
Complete Ingress Definition
Together, you can define complete Ingress resources combining paths, types, and associated backends:
#Ingress: {
metadata?: metav1.#ObjectMeta @go(ObjectMeta) @protobuf(1,bytes,opt)
spec: {
rules: [...#IngressRule] @go(Rules,[]IngressRule) @protobuf(1,bytes,rep)
}
}
In this example, the rules
field contains one or more IngressRule
definitions, allowing multiple paths and backends to be defined under a single Ingress.
Conclusion
Timoni enables sophisticated routing capabilities through the efficient use of HTTP Ingress paths and rules. The defined types of path matching (Exact
, Prefix
, ImplementationSpecific
) allow developers to implement precise control over how incoming requests are matched and forwarded to their respective backends.
References
The above routing information is derived from the definitions within the codebase located in:
examples/minimal/cue.mod/gen/k8s.io/api/networking/v1/types_go_gen.cue
This resource delineates the handling of paths in Ingress configurations, elucidating the structures and types employed for routing within Kubernetes environments.