Skip to content

Commit

Permalink
Update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
duwen committed Jan 31, 2019
1 parent 5966a95 commit 78339f2
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 76 deletions.
71 changes: 19 additions & 52 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 31 additions & 11 deletions README-ZH.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


文档语言: [English](https://github.com/flutterchina/dio) | [中文简体](https://github.com/flutterchina/dio/blob/flutter/README-ZH.md)
文档语言: [English](https://github.com/flutterchina/dio) | [中文简体](README-ZH.md)

# dio

Expand All @@ -14,7 +14,7 @@ dependencies:
dio: ^2.0.x // 请使用pub上2.0分支的最新版本
```
如果您是1.0的用户,可以参照此文档升级到2.0,详情请查看 Change log 。
如果您是1.0的用户,可以参照此文档升级到2.0,详情请查看 [Change log](https://github.com/flutterchina/dio/blob/master/CHANGELOG.md)
## 一个极简的示例
Expand All @@ -33,7 +33,21 @@ void getHttp() async {

## 内容列表

[TOC]
- [示例](#示例)
- [Dio APIs](#dio-apis)
- [请求配置](#请求配置)
- [响应数据](#响应数据)
- [拦截器](#拦截器)
- [Cookie管理](#cookie管理)
- [错误处理](#错误处理)
- [使用application/x-www-form-urlencoded编码](#使用applicationx-www-form-urlencoded编码)
- [FormData](#formdata)
- [转换器](#转换器)
- [HttpClientAdapter](#httpclientadapter )
- [设置Http代理](#设置Http代理)
- [Https证书校验](#Https证书校验)
- [请求取消](#请求取消)
- [Features and bugs](#features-and-bugs)


## 示例
Expand Down Expand Up @@ -109,7 +123,7 @@ response = await dio.post(
);
```

…你可以在这里获取所有[示例代码](https://github.com/flutterchina/dio/tree/flutter/example).
…你可以在这里获取所有[示例代码](https://github.com/flutterchina/dio/tree/master/example).

## Dio APIs

Expand Down Expand Up @@ -224,7 +238,7 @@ Dio实例的核心API是 :
}
```

这里有一个完成的[示例](https://github.com/flutterchina/dio/blob/flutter/example/options.dart).
这里有一个完成的[示例](https://github.com/flutterchina/dio/blob/master/example/options.dart).

## 响应数据

Expand Down Expand Up @@ -375,7 +389,7 @@ dio.interceptors.add(InterceptorsWrapper(
));
```

完整的示例代码请点击 [这里](https://github.com/flutterchina/dio/blob/flutter/example/interceptorLock.dart).
完整的示例代码请点击 [这里](https://github.com/flutterchina/dio/blob/master/example/interceptor_lock.dart).

### 日志

Expand Down Expand Up @@ -484,7 +498,7 @@ dio.options.contentType=ContentType.parse("application/x-www-form-urlencoded");
dio.post("/info",data:{"id":5}, options: new Options(contentType:ContentType.parse("application/x-www-form-urlencoded")));
```

这里有一个[示例](https://github.com/flutterchina/dio/blob/flutter/example/options.dart).
这里有一个[示例](https://github.com/flutterchina/dio/blob/6de8289ea71b0b7803654caaa2e9d3d47a588ab7/example/options.dart#L41).

## FormData

Expand All @@ -501,7 +515,7 @@ response = await dio.post("/info", data: formData);

> 注意: 只有 post 方法支持发送 FormData.
这里有一个完整的[示例](https://github.com/flutterchina/dio/blob/flutter/example/formdata.dart).
这里有一个完整的[示例](https://github.com/flutterchina/dio/blob/master/example/formdata.dart).

## 转换器

Expand All @@ -515,7 +529,7 @@ response = await dio.post("/info", data: formData);

*请求拦截器* >> *请求转换器* >> *发起请求* >> *响应转换器* >> *响应拦截器* >> *最终结果*

这是一个自定义转换器的[示例](https://github.com/wendux/dio/blob/flutter/example/Transformer.dart).
这是一个自定义转换器的[示例](https://github.com/flutterchina/dio/blob/master/example/transfomer.dart).

## HttpClientAdapter

Expand All @@ -541,7 +555,7 @@ Dio 使用`DefaultHttpClientAdapter`作为其默认HttpClientAdapter,`DefaultH
};
```

完整的示例请查看[这里](https://github.com/wendux/dio/tree/flutter/example/proxy.dart).
完整的示例请查看[这里](https://github.com/flutterchina/dio/blob/master/example/proxy.dart).

### Https证书校验

Expand Down Expand Up @@ -595,7 +609,7 @@ token.cancel("cancelled");

> 注意: 同一个cancel token 可以用于多个请求,当一个cancel token取消时,所有使用该cancel token的请求都会被取消。
完整的示例请参考[取消示例](https://github.com/flutterchina/dio/blob/flutter/example/cancelRequest.dart).
完整的示例请参考[取消示例](https://github.com/flutterchina/dio/blob/master/example/cancel_request.dart).



Expand All @@ -613,3 +627,9 @@ token.cancel("cancelled");
Please file feature requests and bugs at the [issue tracker][tracker].

[tracker]: https://github.com/flutterchina/dio

## 支持

觉得对有帮助,请作者喝杯咖啡 (微信):

![](https://cdn.jsdelivr.net/gh/flutterchina/[email protected]/docs/imgs/pay.jpeg)
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Language: [English](https://github.com/flutterchina/dio) | [中文简体](https://github.com/flutterchina/dio/blob/flutter/README-ZH.md)
Language: [English](README.md) | [中文简体](README-ZH.md)

# dio

Expand All @@ -13,9 +13,9 @@ A powerful Http client for Dart, which supports Interceptors, Global configurati

```yaml
dependencies:
dio: x.x.x #latest version
dio: 2.0.x #latest version
```
If you are using 1.0.x , this doc can help you upgrade to 2.0.x. [Change log](https://github.com/flutterchina/dio/blob/master/CHANGELOG.md)
## Super simple to use
```dart
Expand Down Expand Up @@ -43,6 +43,8 @@ void getHttp() async {

- [Interceptors](#interceptors)

- [Cookie Manager](#cookie-manager)

- [Handling Errors](#handling-errors)

- [Using application/x-www-form-urlencoded format](#using-application/x-www-form-urlencoded-format)
Expand All @@ -57,7 +59,7 @@ void getHttp() async {

- [Cancellation](#cancellation)

- [Cookie Manager](#cookie-manager)
- [HttpClientAdapter](#httpclientadapter )

- [Features and bugs](#features-and-bugs)

Expand Down Expand Up @@ -135,7 +137,7 @@ response = await dio.post(
);
```

…you can find all examples code [here](https://github.com/flutterchina/dio/tree/flutter/example).
…you can find all examples code [here](https://github.com/flutterchina/dio/tree/master/example).

## Dio APIs

Expand Down Expand Up @@ -254,7 +256,7 @@ The Options class describes the http request information and configuration. Each
}
```

There is a complete example [here](https://github.com/flutterchina/dio/tree/flutter/example/options.dart).
There is a complete example [here](https://github.com/flutterchina/dio/blob/master/example/options.dart).

## Response Schema

Expand Down Expand Up @@ -402,7 +404,7 @@ dio.interceptors.add(InterceptorsWrapper(
));
```

For complete codes click [here](https://github.com/flutterchina/dio/tree/1.1.x/example/interceptorLock.dart).
For complete codes click [here](https://github.com/flutterchina/dio/blob/master/example/interceptor_lock.dart).

### Log

Expand Down Expand Up @@ -511,7 +513,7 @@ dio.options.contentType=ContentType.parse("application/x-www-form-urlencoded");
dio.post("/info",data:{"id":5}, options: new Options(contentType:ContentType.parse("application/x-www-form-urlencoded")));
```

There is an example [here](https://github.com/flutterchina/dio/tree/flutter/example/options.dart).
There is an example [here](https://github.com/flutterchina/dio/blob/6de8289ea71b0b7803654caaa2e9d3d47a588ab7/example/options.dart#L41).

## Sending FormData

Expand All @@ -528,15 +530,15 @@ response = await dio.post("/info", data: formData);

> Note: Just the post method suppots FormData.
There is a complete example [here](https://github.com/flutterchina/dio/tree/flutter/example/formdata.dart).
There is a complete example [here](https://github.com/flutterchina/dio/blob/master/example/formdata.dart).

## Transformer

`Transformer` allows changes to the request/response data before it is sent/received to/from the server. This is only applicable for request methods 'PUT', 'POST', and 'PATCH'. Dio has already implemented a `DefaultTransformer`, and as the default `Transformer`. If you want to customize the transformation of request/response data, you can provide a `Transformer` by your self, and replace the `DefaultTransformer` by setting the `dio.transformer`.

There is an example for [customizing Transformer](https://github.com/flutterchina/dio/blob/flutter/example/Transformer.dart).
There is an example for [customizing Transformer](https://github.com/flutterchina/dio/blob/master/example/transfomer.dart).

## Adapter
## HttpClientAdapter

HttpClientAdapter is a bridge between Dio and HttpClient.

Expand Down Expand Up @@ -568,7 +570,7 @@ dio.httpClientAdapter = new DefaultHttpClientAdapter();
};
```

There is a complete example [here](https://github.com/flutterchina/dio/tree/flutter/example/proxy.dart).
There is a complete example [here](https://github.com/flutterchina/dio/blob/master/example/proxy.dart).

### Https certificate verification

Expand Down Expand Up @@ -613,7 +615,7 @@ dio.get(url2, cancelToken: token);
token.cancel("cancelled");
```

There is a complete example [here](https://github.com/flutterchina/dio/tree/flutter/example/cancelRequest.dart).
There is a complete example [here](https://github.com/flutterchina/dio/blob/master/example/cancel_request.dart).

## Copyright & License

Expand Down

0 comments on commit 78339f2

Please sign in to comment.