vadymmarkov / Malibu

:surfer: Malibu is a networking library built on promises
https://vadymmarkov.github.io
Other
414 stars 39 forks source link

Make `preProcessRequest` return a promise (or give middleware access to the Request) #116

Open codeOfRobin opened 5 years ago

codeOfRobin commented 5 years ago

Hi Vadym!

We have an Auth SDK at work that exposes a simple function:

public func addAuthentication(to request: Request, completion: (TypedResult<Request, TokenStorageError>) -> Void) 

(since we don't want clients to have access to the access tokens directly)

Since this API works asynchronously, we can't add this to preProcessRequest (which is synchronous) or to middleware (since that doesn't have access to the request). Is there a "right" way to do this?

vadymmarkov commented 5 years ago

I'm afraid it's not possible with the current implementation. Perhaps preProcessRequest should be turned into async function.