Added docs for OkHttp integration (#144)

Summary:
This PR includes documentation for using the `SonarOkhttpInterceptor` for applications using the `OkHttp` network stack. The docs were modelled on the [Stetho docs](http://facebook.github.io/stetho/#enable-network-inspection)

Fixes #22.
Pull Request resolved: https://github.com/facebook/Sonar/pull/144

Differential Revision: D8780506

Pulled By: danielbuechele

fbshipit-source-id: fb2ddd4356b421c3baf0a80a410dd579ebc1bd8d
This commit is contained in:
Arvind Menon
2018-07-10 03:17:49 -07:00
committed by Facebook Github Bot
parent dfddcc483e
commit dad05de943

View File

@@ -16,9 +16,24 @@ To use the network plugin, you need to add the plugin to your Sonar client insta
```java
import com.facebook.sonar.plugins.network.NetworkSonarPlugin;
client.addPlugin(new NetworkSonarPlugin());
NetworkSonarPlugin networkSonarPlugin = new NetworkSonarPlugin();
client.addPlugin(networkSonarPlugin);
```
#### OkHttp Integration
If you are using the popular OkHttp library, you can use the Interceptors system to automatically hook into your existing stack.
```java
import com.facebook.sonar.plugins.network.SonarOkhttpInterceptor;
new OkHttpClient.Builder()
.addNetworkInterceptor(new SonarOkhttpInterceptor(networkSonarPlugin))
.build();
```
As interceptors can modify the request and response, add the Sonar interceptor after all others to get an accurate view of the network traffic.
### iOS
```objective-c