Structure
EndpointBuilder
@resultBuilder
public struct EndpointBuilder
A struct
defining a result builder capable of generating a single
endpoint from a collection of components.
This resultBuilder
enforces the following rules:
-
you MUST have at least
1
Path
-
successive
Component
s of the same type,Path
s andResponse
s will inherit their previous values, if supported, otherwise they will override it -
no explicit
Response
meansSingle
will outputDefaultResponse
-
Endpoint
s only return themselves
Methods
buildExpression(_:)
public static func buildExpression<C: Component>(_ expression: C) -> Components
Turn a single component into a collection.
Parameters
Name | Type | Description |
---|---|---|
expression | C |
Some |
Returns
Some Components
.
buildExpression(_:)
Turn a valid path into itself.
Parameters
Name | Type | Description |
---|---|---|
expression | Path |
A valid |
Returns
A valid Path
.
buildExpression(_:)
Turn a valid response into itself.
Parameters
Name | Type | Description |
---|---|---|
expression | Response<I, O> |
A valid |
Returns
A valid Response
.
buildExpression(_:)
public static func buildExpression<E: Endpoint>(_ expression: E) -> E
Turn a valid endpoint into itself.
Parameters
Name | Type | Description |
---|---|---|
expression | E |
Some |
Returns
Some Endpoint
.
buildEither(first:)
Turn a single path into itself.
Parameters
Name | Type | Description |
---|---|---|
component | Path |
A valid |
Returns
A valid Path
.
buildEither(second:)
Turn a single path into itself.
Parameters
Name | Type | Description |
---|---|---|
component | Path |
A valid |
Returns
A valid Path
.
buildOptional(_:)
public static func buildOptional(_ component: Components?) -> Components
Turn a single component into a collection.
Parameters
Name | Type | Description |
---|---|---|
component | Components? |
A valid |
Returns
A valid Path
.
buildEither(first:)
public static func buildEither(first component: Components) -> Components
Turn a collction of components into itself.
Parameters
Name | Type | Description |
---|---|---|
component | Components |
Some |
Returns
Some Components
.
buildEither(second:)
public static func buildEither(second component: Components) -> Components
Turn a collction of components into itself.
Parameters
Name | Type | Description |
---|---|---|
component | Components |
Some |
Returns
Some Components
.
buildLimitedAvailability(_:)
public static func buildLimitedAvailability<T>(_ component: T) -> T
Turn an item into itself.
Parameters
Name | Type | Description |
---|---|---|
component | T |
Some item. |
Returns
Some item.
buildPartialBlock(first:)
public static func buildPartialBlock(first content: Components) -> Components
Build an endpoint request, starting from some components.
Parameters
Name | Type | Description |
---|---|---|
content | Components |
Some |
Returns
Some Components
.
buildPartialBlock(first:)
public static func buildPartialBlock(first content: Path) -> TupleEndpoint<DefaultResponse>
Build an endpoint request, starting from a path.
Parameters
Name | Type | Description |
---|---|---|
response | A valid |
Returns
A valid TupleItem
.
buildPartialBlock(first:)
public static func buildPartialBlock<O>(first content: Response<DefaultResponse, O>) -> Response<DefaultResponse, O>
Build an endpoint request, starting from the response.
-
paramter content: A valid
Response
.
Returns
Some Response
.
buildPartialBlock(first:)
public static func buildPartialBlock<E: Endpoint>(first content: E) -> E
Build an endpoint request, starting from some endpoint.
Parameters
Name | Type | Description |
---|---|---|
content | E |
Some |
Returns
Some Endpoint
.
buildPartialBlock(accumulated:next:)
public static func buildPartialBlock(accumulated: Components, next: Components) -> Components
Accumulate an endpoint request, adding to some components.
Parameters
Name | Type | Description |
---|---|---|
accumulated | Components |
Some |
next | Components |
Some |
Returns
Some Components
.
buildPartialBlock(accumulated:next:)
public static func buildPartialBlock(accumulated: Components, next: Path) -> TupleEndpoint<DefaultResponse>
Accumulate an endpoint request, adding to some components.
Parameters
Name | Type | Description |
---|---|---|
accumulated | Components |
Some |
next | Path |
A valid |
Returns
A valid TupleItem
.
buildPartialBlock(accumulated:next:)
public static func buildPartialBlock<O>(accumulated: Components, next: Response<DefaultResponse, O>) -> TupleItem<Components, Response<DefaultResponse, O>>
Accumulate an endpoint request, adding to some components.
Parameters
Name | Type | Description |
---|---|---|
accumulated | Components |
Some |
next | Response<DefaultResponse, O> |
A valid |
Returns
A valid TupleItem
.
buildPartialBlock(accumulated:next:)
public static func buildPartialBlock<I, O>(accumulated: Response<DefaultResponse, I>, next: Response<I, O>) -> Response<DefaultResponse, O>
Accumulate a response, adding to some response.
Parameters
Name | Type | Description |
---|---|---|
accumulated | Response<DefaultResponse, I> |
A valid |
next | Response<I, O> |
A valid |
Returns
A valid Response
.
buildPartialBlock(accumulated:next:)
public static func buildPartialBlock<O>(accumulated: Response<DefaultResponse, O>, next: Components) -> TupleItem<Components, Response<DefaultResponse, O>>
Accumulate an endpoint request, adding to some response.
Parameters
Name | Type | Description |
---|---|---|
accumulated | Response<DefaultResponse, O> |
A valid |
next | Components |
Some |
Returns
A valid TupleItem
.
buildPartialBlock(accumulated:next:)
public static func buildPartialBlock<O>(accumulated: Response<DefaultResponse, O>, next: Path) -> TupleEndpoint<O>
Accumulate an endpoint request, adding to some response.
Parameters
Name | Type | Description |
---|---|---|
accumulated | Response<DefaultResponse, O> |
A valid |
next | Path |
A valid |
Returns
Some Single
.
buildPartialBlock(accumulated:next:)
public static func buildPartialBlock<O>(accumulated: TupleItem<Components, Response<DefaultResponse, O>>, next: Components) -> TupleItem<Components, Response<DefaultResponse, O>>
Accumulate an endpoint request, adding to a tuple item.
Parameters
Name | Type | Description |
---|---|---|
accumulated | TupleItem<Components, Response<DefaultResponse, O>> |
A valid |
next | Components |
Some |
Returns
A valid TupleItem
.
buildPartialBlock(accumulated:next:)
public static func buildPartialBlock<I, O>(accumulated: TupleItem<Components, Response<DefaultResponse, I>>, next: Response<I, O>) -> TupleItem<Components, Response<DefaultResponse, O>>
Accumulate an endpoint request, adding to a tuple item.
Parameters
Name | Type | Description |
---|---|---|
accumulated | TupleItem<Components, Response<DefaultResponse, I>> |
A valid |
next | Response<I, O> |
A valid |
Returns
A valid TupleItem
.
buildPartialBlock(accumulated:next:)
public static func buildPartialBlock<O>(accumulated: TupleItem<Components, Response<DefaultResponse, O>>, next: Path) -> TupleEndpoint<O>
Accumulate an endpoint request, adding to a tuple item.
Parameters
Name | Type | Description |
---|---|---|
accumulated | TupleItem<Components, Response<DefaultResponse, O>> |
A valid |
next | Path |
A valid |
Returns
Some Single
.
buildPartialBlock(accumulated:next:)
public static func buildPartialBlock<O>(accumulated: TupleEndpoint<O>, next: Components) -> TupleEndpoint<O>
Accumulate an endpoint request, adding to a tuple item.
Parameters
Name | Type | Description |
---|---|---|
accumulated | TupleEndpoint<O> |
A valid |
next | Components |
Some |
Returns
A valid TupleEndpoint
.
buildPartialBlock(accumulated:next:)
public static func buildPartialBlock<I, O>(accumulated: TupleEndpoint<I>, next: Response<I, O>) -> TupleEndpoint<O>
Accumulate an endpoint request, adding to a tuple item.
Parameters
Name | Type | Description |
---|---|---|
accumulated | TupleEndpoint<I> |
A valid |
next | Response<I, O> |
A valid |
Returns
A valid TupleEndpoint
.
buildPartialBlock(accumulated:next:)
public static func buildPartialBlock<O>(accumulated: TupleEndpoint<O>, next: Path) -> TupleEndpoint<O>
Accumulate an endpoint request, adding to a tuple item.
Parameters
Name | Type | Description |
---|---|---|
accumulated | TupleEndpoint<O> |
A valid |
next | Path |
A valid |
Returns
A valid TupleEndpoint
.
buildFinalResult(_:)
public static func buildFinalResult<O>(_ component: TupleEndpoint<O>) -> Single<O>
Resolve a valid tuple endpoint.
Parameters
Name | Type | Description |
---|---|---|
content | A valid |
Returns
A valid Single
.
buildFinalResult(_:)
public static func buildFinalResult<E: Endpoint>(_ component: E) -> E
Resolve some endpoint.
Parameters
Name | Type | Description |
---|---|---|
content | Some |
Returns
Some Endpoint
.