Moya: Generate cURL output from Moya request?

Created on 30 Mar 2017  路  3Comments  路  Source: Moya/Moya

To start, I posted this on StackOverflow
I'm using Moya 7.0.4

I need to print the cURL for a network request.

Usually, in Alamofire 4, I would do something like this:

    let req = Alamofire.request(someURLRequestConvertible)
    debugPrint(req) // will print cURL

My call site for Moya looks like this:

    MyMoyaProvider<MyEndPoints>.request(MyEndPoints.login(params)) { (result) in }

I've checked out the documentation for Moya, but I can't seem to get the results I'm looking for. I enabled the NetworkLoggingPlugin but still unsure how to print cURL for certain requests. Can someone help me find the proper way to print the Moya request's cURL to console?

question

Most helpful comment

If you initialize your NetworkLoggerPlugin, its cURL flag is set to false by default. Initializing it like NetworkLoggerPlugin(cURL: true), willSendRequest should print the cURL. Does that help?

All 3 comments

If you initialize your NetworkLoggerPlugin, its cURL flag is set to false by default. Initializing it like NetworkLoggerPlugin(cURL: true), willSendRequest should print the cURL. Does that help?

@BasThomas Yep! Perfect 馃憣馃徏

Cool, thanks @BasThomas I'll close the issue :wink:

Was this page helpful?
0 / 5 - 0 ratings