LinkResponse
public struct LinkResponse : Decodable, Sendable
Represents a hypermedia link in Horizon API responses.
Horizon uses HAL (Hypertext Application Language) for responses, which includes links to related resources. Links provide navigation between related resources without requiring clients to construct URLs manually.
Links may be templated (contain placeholders like {cursor}, {limit}) that clients can fill in with values, or they may be direct URLs ready to use.
Example usage:
let account: AccountResponse = // ... get account
// Direct link (not templated)
if let transactionsURL = account.links.transactions?.href {
// Use URL directly to fetch transactions
}
// Templated link - requires parameter substitution
if let templated = account.links.transactions?.templated, templated {
// Link contains placeholders like {cursor}, {limit}, {order}
// Need to substitute values before using
}
See also:
- HAL Specification
- PagingLinksResponse for pagination links
-
URL of the linked resource. May contain URI template placeholders if templated is true.
Declaration
Swift
public let href: String -
If true, href contains URI template variables that must be substituted with values. Common variables: {cursor}, {limit}, {order}. If false or nil, href is a direct URL.
Declaration
Swift
public let templated: Bool? -
Initializer - creates a new instance by decoding from the given decoder.
Declaration
Swift
public init(from decoder: Decoder) throwsParameters
decoderThe decoder containing the data
View on GitHub
Install in Dash