vadymmarkov / Malibu

:surfer: Malibu is a networking library built on promises

Home Page:https://vadymmarkov.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

codeOfRobin opened this issue · comments

commented

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?

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