Skip to content

Add some basic support for networking interceptors #118

Description

@brendanlensink

Adding interceptors to Netable will be necessary for working with our mocking libraries.

I think we can be pretty flexible here and offload most of the work to the actual interceptors, but we need to provide something at the base level to allow interceptors to interface with Netable.

I think a good starting place might be:

  • Introduce new top level types called Interceptor and RequestInterceptor that look something like

     struct Interceptor {
       let interceptors: [RequestInterceptor]
    }
    
     protocol RequestInterceptor {
       func adapt(_ request: URLRequest, instance: Netable) async throws -> URLRequest {}
    }
    
  • Add optional parameters to both Netable.init and Netable.request that accept an Interceptor

  • Modify request to apply any interceptors to our URLRequest before it gets sent off

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions