Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get concrete Request, like DownloadRequest, UploadRequest etc. #2343

Open
Madara2hor opened this issue Mar 25, 2024 · 0 comments
Open

Get concrete Request, like DownloadRequest, UploadRequest etc. #2343

Madara2hor opened this issue Mar 25, 2024 · 0 comments

Comments

@Madara2hor
Copy link

Version
Moya: 15.0.3

Problem/Question
In some cases I need to get UploadRequest to perform operation like cancel, suspend and resume it, but Moya return only Cancellable.
So there is the question: how can I get UploadRequest that Alamofire provide or manage the request using Moya? Should I use Alamofire directly?

Sample code
I've try to do something like that, but, because of internal access modifier of CancellableWrapper, I can't cast it to get UploadRequest.

func handleRequest(_ request: any Cancellable) {
    guard 
        let wrapper = request as? CancellableWrapper,
        let token = wrapper.innerCancellable as? CancellableToken
        let uploadRequest = token.request as? UploadRequest
    else {
        return
    }

    // NOTE: Do something with UploadRequest
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant