Struct RequestUriBuilder
- Namespace
- MassiveDotNet.Http
- Assembly
- MassiveDotNet.dll
Composes a relative request URI, escaping path segments and query values as it goes.
public ref struct RequestUriBuilder
- Inherited Members
Remarks
This is a ref struct, so it cannot cross an await.
Build the URI to completion with ToUriString() before issuing the request.
Optional query parameters are skipped when null, which lets generated endpoint code append every supported parameter unconditionally.
Constructors
RequestUriBuilder(Span<char>)
Initializes a builder over caller-supplied scratch space.
public RequestUriBuilder(Span<char> initialBuffer)
Parameters
Methods
AppendPathLiteral(scoped ReadOnlySpan<char>)
Appends a literal, already-safe portion of the path, such as "/v2/aggs/ticker/".
public void AppendPathLiteral(scoped ReadOnlySpan<char> value)
Parameters
valueReadOnlySpan<char>The literal path text to append verbatim.
AppendPathSegment(int)
Appends an integer path segment.
public void AppendPathSegment(int value)
Parameters
valueintThe segment value, for example an aggregate multiplier.
AppendPathSegment(string)
Appends a caller-supplied path segment, percent-escaping it.
public void AppendPathSegment(string value)
Parameters
valuestringThe segment value, for example a ticker symbol.
AppendQuery(scoped ReadOnlySpan<char>, bool?)
Appends a boolean query parameter, skipping it when null.
public void AppendQuery(scoped ReadOnlySpan<char> name, bool? value)
Parameters
nameReadOnlySpan<char>The parameter name, which must already be URI-safe.
valuebool?The parameter value, or null to omit the parameter.
AppendQuery(scoped ReadOnlySpan<char>, double?)
Appends a floating-point query parameter in invariant culture, skipping it when null.
public void AppendQuery(scoped ReadOnlySpan<char> name, double? value)
Parameters
nameReadOnlySpan<char>The parameter name, which must already be URI-safe.
valuedouble?The parameter value, or null to omit the parameter.
AppendQuery(scoped ReadOnlySpan<char>, int?)
Appends an integer query parameter, skipping it when null.
public void AppendQuery(scoped ReadOnlySpan<char> name, int? value)
Parameters
nameReadOnlySpan<char>The parameter name, which must already be URI-safe.
valueint?The parameter value, or null to omit the parameter.
AppendQuery(scoped ReadOnlySpan<char>, long?)
Appends a 64-bit integer query parameter, skipping it when null.
public void AppendQuery(scoped ReadOnlySpan<char> name, long? value)
Parameters
nameReadOnlySpan<char>The parameter name, which must already be URI-safe.
valuelong?The parameter value, or null to omit the parameter.
AppendQuery(scoped ReadOnlySpan<char>, string?)
Appends a string query parameter, skipping it when null.
public void AppendQuery(scoped ReadOnlySpan<char> name, string? value)
Parameters
nameReadOnlySpan<char>The parameter name, which must already be URI-safe.
valuestringThe parameter value, or null to omit the parameter.
AppendQuery<T>(scoped ReadOnlySpan<char>, ArrayFilter<T>?)
Appends an array filter as its comparator parameters, skipping it when null or unset.
public void AppendQuery<T>(scoped ReadOnlySpan<char> name, ArrayFilter<T>? filter)
Parameters
nameReadOnlySpan<char>The field's base name, which must already be URI-safe.
filterArrayFilter<T>?The filter, or null to omit the field entirely.
Type Parameters
TThe element type: string, int, long, double, LocalDate, DateOrTimestamp, or DateOrNanoseconds.
Exceptions
- NotSupportedException
Tis not one of the supported element types.
AppendQuery<T>(scoped ReadOnlySpan<char>, Filter<T>?)
Appends a range-or-set filter as its comparator parameters, skipping it when null or unset.
public void AppendQuery<T>(scoped ReadOnlySpan<char> name, Filter<T>? filter)
Parameters
nameReadOnlySpan<char>The field's base name, which must already be URI-safe.
filterFilter<T>?The filter, or null to omit the field entirely.
Type Parameters
TThe element type: string, int, long, double, LocalDate, DateOrTimestamp, or DateOrNanoseconds.
Exceptions
- NotSupportedException
Tis not one of the supported element types.
AppendQuery<T>(scoped ReadOnlySpan<char>, RangeFilter<T>?)
Appends a range filter as its comparator parameters, skipping it when null or unset.
public void AppendQuery<T>(scoped ReadOnlySpan<char> name, RangeFilter<T>? filter)
Parameters
nameReadOnlySpan<char>The field's base name, which must already be URI-safe.
filterRangeFilter<T>?The filter, or null to omit the field entirely.
Type Parameters
TThe element type: string, int, long, double, LocalDate, DateOrTimestamp, or DateOrNanoseconds.
Exceptions
- NotSupportedException
Tis not one of the supported element types.
AppendQuery<T>(scoped ReadOnlySpan<char>, SetFilter<T>?, bool)
Appends a set filter as its comparator parameters, skipping it when null or unset.
public void AppendQuery<T>(scoped ReadOnlySpan<char> name, SetFilter<T>? filter, bool hasExactForm = true)
Parameters
nameReadOnlySpan<char>The field's base name, which must already be URI-safe.
filterSetFilter<T>?The filter, or null to omit the field entirely.
hasExactFormboolWhether the endpoint declares the plain
fieldparameter. When it declares onlyfield.any_of, an equality is rendered as a one-element set, which means the same thing.
Type Parameters
TThe element type: string, int, long, double, LocalDate, DateOrTimestamp, or DateOrNanoseconds.
Exceptions
- NotSupportedException
Tis not one of the supported element types.
AppendQuery<T>(scoped ReadOnlySpan<char>, T[]?)
Appends an array-typed query parameter as one comma-joined value, skipping it when null or empty.
public void AppendQuery<T>(scoped ReadOnlySpan<char> name, T[]? values)
Parameters
nameReadOnlySpan<char>The parameter name, which must already be URI-safe.
valuesT[]The values, or null or empty to omit the parameter.
Type Parameters
TThe element type: string, int, long, double, LocalDate, DateOrTimestamp, or DateOrNanoseconds.
Remarks
This is the field itself as a list, such as the snapshot operations' tickers, not a
comparator set: there is no .any_of suffix. The OpenAPI description declares no
style or explode for these parameters, and the default that implies is the
repeated-key form, but the service reads only one value from that form (D19). An empty
array is omitted rather than sent as name=, like every other optional parameter.
Exceptions
- NotSupportedException
Tis not one of the supported element types.
Dispose()
Returns any pooled buffer without materializing a string.
public void Dispose()
ToUriString()
Materializes the composed URI and returns any pooled buffer.
public string ToUriString()
Returns
- string
The relative URI, including its query string when one was appended.