Structs

The following structs are available globally.

  • The options for a request. It captures headers, query-string and request body.

    See more

    Declaration

    Swift

    public struct Options
  • This struct encodes the path to an operation on a remote resource or a collection. It uses generics and phantom-types to encode the Resource it relates to, the response type — a collection or single resource — and the HTTP method.

    It can then be passed to the call function on the Service type, which will execute the encoded operation.

    Here is an example of a path for deleting a record:

    let path = Path<User, SingularPath, DELETE>(path: "user/1")
    

    Note: In general usage, you should not need to construct an instance of this type. Instead they are generated by functions defined on Resource.

    See more

    Declaration

    Swift

    public struct Path<R: Resource, Path, Method>
  • This struct encodes the partial path to an operation on a remote resource or a collection. It has the same semantics as Path — encoding method etc. — but cannot be used to make a request. Instead it has to be appended to a Path.

    Imagine we have a hierarchy like this: /groups/{group_id}/users/{user_id}. We don’t want to allow a path like /users/1 to be used to make a request. So we encode it as a ChildPath. We would turn it into a qualified path using the /(_:_:) operator.

    Note: In general usage, you should not need to construct an instance of this type. Instead they are generated by functions defined on Resource.

    See more

    Declaration

    Swift

    public struct ChildPath<R: NestedResource, Path, Method>
  • Encodes a request — path, URL, body etc — and is generated by the Service. It’s generic types are there for the Path instance it captures.

    See more

    Declaration

    Swift

    public struct Request<R: Resource, P, M>
  • A struct which wraps interaction with a remote API. It delegates all the HTTP requests to the underlying adapter.

    See more

    Declaration

    Swift

    public struct Service<Adapter: HTTPAdapter>