PluginType

public protocol PluginType

A Moya Plugin receives callbacks to perform side effects wherever a request is sent or received.

for example, a plugin may be used to - log network requests - hide and show a network activity indicator - inject additional information into a request

  • prepare(_:target:) Default implementation

    Called to modify a request before sending.

    Default Implementation

    Declaration

    Swift

    func prepare(_ request: URLRequest, target: TargetType) -> URLRequest
  • willSend(_:target:) Default implementation

    Called immediately before a request is sent over the network (or stubbed).

    Default Implementation

    Declaration

    Swift

    func willSend(_ request: RequestType, target: TargetType)
  • didReceive(_:target:) Default implementation

    Called after a response has been received, but before the MoyaProvider has invoked its completion handler.

    Default Implementation

    Declaration

    Swift

    func didReceive(_ result: Result<Moya.Response, MoyaError>, target: TargetType)
  • process(_:target:) Default implementation

    Called to modify a result before completion.

    Default Implementation

    Declaration

    Swift

    func process(_ result: Result<Moya.Response, MoyaError>, target: TargetType) -> Result<Moya.Response, MoyaError>