Skip to content

Endpoint

Josh Wright edited this page Jan 14, 2021 · 3 revisions

Endpoint

Endpoint is an abstraction around making REST requests. It includes a Request type, representing the data needed to make the request, and a Response type, representing the expected response from the server.

public struct Endpoint<Request: EndpointRequest, Response: Codable>

Endpoints are defined via property wrapped (@GET, @POST, etc...) properties on an EndpointGroup.

Endpoints are intended to be used on either client or server for requesting external endpoints or on server for providing and validating endpoints. There are partner libraries (PapyrusAlamofire and Alchemy) for requesting or validating endpoints on client or server platforms.

Properties

method

The method, or verb, of this endpoint.

let method: EndpointMethod

path

The path of this endpoint, relative to self.baseURL

var path: String

baseURL

The baseURL of this endpoint.

var baseURL: String = ""

Methods

parameters(dto:)

Gets any information that may be needed to request this Endpoint.

public func parameters(dto: Request) throws -> RequestComponents

Parameters

  • dto: An instance of Endpoint.Request.

Throws

any errors that may occur when parsing out data from the Endpoint.

Returns

A struct containing any information needed to request this endpoint with the provided instance of Request.

with(baseURL:)

Creates a copy of this Endpoint with the provided baseURL.

public func with(baseURL: String) -> Self

Parameters

  • baseURL: The baseURL for the Endpoint.

Returns

A copy of this Endpoint with the baseURL.

Alchemy
Types
Protocols
Global Typealiases
Global Variables
Global Functions
Fusion
Types
Protocols
Papyrus
Types
Protocols
Clone this wiki locally