WebService

@objc
public protocol WebService

WebService is a protocol which helps you write your network requests in a declarative, type-safe and expressive way.

You start by creating a class, putting in your server’s base URL & a network interface, and begin writing your network requests as functions

  • The Base URL of the server. Needs to have a scheme (http/https), and a URL.

    Example: https://example.com

    A trailing forward slash in not required at the end of the URL.

    Declaration

    Swift

    static var serverURL: String { get set }
  • The network interface this WebService will use to communicate with the network.

    This is usually a class conforming to the WebServiceNetworkInterface protocol, holding an instance of Swifty with your custom Interceptors and Constraints.

    Declaration

    Swift

    static var networkInterface: WebServiceNetworkInterface { get set }
  • server Extension method

    A BaseResource created from the server URL of the WebService

    Use this as the starting point while creating requests in your WebService.

    Declaration

    Swift

    public static var server: BaseResource { get }
  • customResource(with:) Extension method

    Can be used to have a custom base URL for a request, instead of the using the WebService’s Server URL

    Declaration

    Swift

    public static func customResource(with baseURL: String) -> BaseResource

    Parameters

    baseURL

    String

    Return Value

    BaseResource