drake hace 3 años
padre
commit
66271c3a59

+ 49 - 0
net/src/main/java/com/drake/net/Net.kt

@@ -48,6 +48,13 @@ object Net {
         block?.invoke(this)
     }
 
+    /**
+     * 同步网络请求
+     *
+     * @param path 请求路径, 如果其不包含http/https则会自动拼接[NetConfig.host]
+     * @param tag 可以传递对象给Request请求, 一般用于在拦截器/转换器中进行针对某个接口行为判断
+     * @param block 函数中可以配置请求参数
+     */
     fun post(
         path: String,
         tag: Any? = null,
@@ -59,6 +66,13 @@ object Net {
         block?.invoke(this)
     }
 
+    /**
+     * 同步网络请求
+     *
+     * @param path 请求路径, 如果其不包含http/https则会自动拼接[NetConfig.host]
+     * @param tag 可以传递对象给Request请求, 一般用于在拦截器/转换器中进行针对某个接口行为判断
+     * @param block 函数中可以配置请求参数
+     */
     fun head(
         path: String,
         tag: Any? = null,
@@ -70,6 +84,13 @@ object Net {
         block?.invoke(this)
     }
 
+    /**
+     * 同步网络请求
+     *
+     * @param path 请求路径, 如果其不包含http/https则会自动拼接[NetConfig.host]
+     * @param tag 可以传递对象给Request请求, 一般用于在拦截器/转换器中进行针对某个接口行为判断
+     * @param block 函数中可以配置请求参数
+     */
     fun options(
         path: String,
         tag: Any? = null,
@@ -81,6 +102,13 @@ object Net {
         block?.invoke(this)
     }
 
+    /**
+     * 同步网络请求
+     *
+     * @param path 请求路径, 如果其不包含http/https则会自动拼接[NetConfig.host]
+     * @param tag 可以传递对象给Request请求, 一般用于在拦截器/转换器中进行针对某个接口行为判断
+     * @param block 函数中可以配置请求参数
+     */
     fun trace(
         path: String,
         tag: Any? = null,
@@ -92,6 +120,13 @@ object Net {
         block?.invoke(this)
     }
 
+    /**
+     * 同步网络请求
+     *
+     * @param path 请求路径, 如果其不包含http/https则会自动拼接[NetConfig.host]
+     * @param tag 可以传递对象给Request请求, 一般用于在拦截器/转换器中进行针对某个接口行为判断
+     * @param block 函数中可以配置请求参数
+     */
     fun delete(
         path: String,
         tag: Any? = null,
@@ -103,6 +138,13 @@ object Net {
         block?.invoke(this)
     }
 
+    /**
+     * 同步网络请求
+     *
+     * @param path 请求路径, 如果其不包含http/https则会自动拼接[NetConfig.host]
+     * @param tag 可以传递对象给Request请求, 一般用于在拦截器/转换器中进行针对某个接口行为判断
+     * @param block 函数中可以配置请求参数
+     */
     fun put(
         path: String,
         tag: Any? = null,
@@ -114,6 +156,13 @@ object Net {
         block?.invoke(this)
     }
 
+    /**
+     * 同步网络请求
+     *
+     * @param path 请求路径, 如果其不包含http/https则会自动拼接[NetConfig.host]
+     * @param tag 可以传递对象给Request请求, 一般用于在拦截器/转换器中进行针对某个接口行为判断
+     * @param block 函数中可以配置请求参数
+     */
     fun patch(
         path: String,
         tag: Any? = null,

+ 49 - 0
net/src/main/java/com/drake/net/NetCoroutine.kt

@@ -33,6 +33,13 @@ inline fun <reified M> CoroutineScope.Get(
     }.execute()
 }
 
+/**
+ * 异步网络请求
+ *
+ * @param path 请求路径, 如果其不包含http/https则会自动拼接[NetConfig.host]
+ * @param tag 可以传递对象给Request, 一般用于在拦截器/转换器中进行针对某个接口行为判断
+ * @param block 函数中可以配置请求参数
+ */
 inline fun <reified M> CoroutineScope.Post(
     path: String,
     tag: Any? = null,
@@ -48,6 +55,13 @@ inline fun <reified M> CoroutineScope.Post(
     }.execute()
 }
 
+/**
+ * 异步网络请求
+ *
+ * @param path 请求路径, 如果其不包含http/https则会自动拼接[NetConfig.host]
+ * @param tag 可以传递对象给Request, 一般用于在拦截器/转换器中进行针对某个接口行为判断
+ * @param block 函数中可以配置请求参数
+ */
 inline fun <reified M> CoroutineScope.Head(
     path: String,
     tag: Any? = null,
@@ -63,6 +77,13 @@ inline fun <reified M> CoroutineScope.Head(
     }.execute()
 }
 
+/**
+ * 异步网络请求
+ *
+ * @param path 请求路径, 如果其不包含http/https则会自动拼接[NetConfig.host]
+ * @param tag 可以传递对象给Request, 一般用于在拦截器/转换器中进行针对某个接口行为判断
+ * @param block 函数中可以配置请求参数
+ */
 inline fun <reified M> CoroutineScope.Options(
     path: String,
     tag: Any? = null,
@@ -78,6 +99,13 @@ inline fun <reified M> CoroutineScope.Options(
     }.execute()
 }
 
+/**
+ * 异步网络请求
+ *
+ * @param path 请求路径, 如果其不包含http/https则会自动拼接[NetConfig.host]
+ * @param tag 可以传递对象给Request, 一般用于在拦截器/转换器中进行针对某个接口行为判断
+ * @param block 函数中可以配置请求参数
+ */
 inline fun <reified M> CoroutineScope.Trace(
     path: String,
     tag: Any? = null,
@@ -93,6 +121,13 @@ inline fun <reified M> CoroutineScope.Trace(
     }.execute()
 }
 
+/**
+ * 异步网络请求
+ *
+ * @param path 请求路径, 如果其不包含http/https则会自动拼接[NetConfig.host]
+ * @param tag 可以传递对象给Request, 一般用于在拦截器/转换器中进行针对某个接口行为判断
+ * @param block 函数中可以配置请求参数
+ */
 inline fun <reified M> CoroutineScope.Delete(
     path: String,
     tag: Any? = null,
@@ -108,6 +143,13 @@ inline fun <reified M> CoroutineScope.Delete(
     }.execute()
 }
 
+/**
+ * 异步网络请求
+ *
+ * @param path 请求路径, 如果其不包含http/https则会自动拼接[NetConfig.host]
+ * @param tag 可以传递对象给Request, 一般用于在拦截器/转换器中进行针对某个接口行为判断
+ * @param block 函数中可以配置请求参数
+ */
 inline fun <reified M> CoroutineScope.Put(
     path: String,
     tag: Any? = null,
@@ -123,6 +165,13 @@ inline fun <reified M> CoroutineScope.Put(
     }.execute()
 }
 
+/**
+ * 异步网络请求
+ *
+ * @param path 请求路径, 如果其不包含http/https则会自动拼接[NetConfig.host]
+ * @param tag 可以传递对象给Request, 一般用于在拦截器/转换器中进行针对某个接口行为判断
+ * @param block 函数中可以配置请求参数
+ */
 inline fun <reified M> CoroutineScope.Patch(
     path: String,
     tag: Any? = null,

+ 4 - 0
net/src/main/java/com/drake/net/exception/ConvertException.kt

@@ -20,6 +20,10 @@ import okhttp3.Response
 
 /**
  * 转换数据异常
+ * @param response 响应信息
+ * @param message 错误描述信息
+ * @param cause 错误原因
+ * @param tag 可携带任意对象, 一般用于在转换器/拦截器中添加然后传递给错误处理器去使用判断
  */
 class ConvertException(
     response: Response,

+ 4 - 0
net/src/main/java/com/drake/net/exception/DownloadFileException.kt

@@ -4,6 +4,10 @@ import okhttp3.Response
 
 /**
  * 下载文件异常
+ * @param response 响应信息
+ * @param message 错误描述信息
+ * @param cause 错误原因
+ * @param tag 可携带任意对象, 一般用于在转换器/拦截器中添加然后传递给错误处理器去使用判断
  */
 class DownloadFileException(
     response: Response,

+ 4 - 1
net/src/main/java/com/drake/net/exception/HttpFailureException.kt

@@ -3,7 +3,10 @@ package com.drake.net.exception
 import okhttp3.Request
 
 /**
- * 实现该接口表示Http请求失败
+ * 该类表示Http请求在服务器响应之前失败
+ * @param request 请求信息
+ * @param message 错误描述信息
+ * @param cause 错误原因
  */
 open class HttpFailureException(
     request: Request,

+ 5 - 1
net/src/main/java/com/drake/net/exception/HttpResponseException.kt

@@ -3,7 +3,11 @@ package com.drake.net.exception
 import okhttp3.Response
 
 /**
- * 实现该接口表示Http请求成功
+ * 该类表示Http请求在服务器响应成功后失败
+ * @param response 响应信息
+ * @param message 错误描述信息
+ * @param cause 错误原因
+ *
  * @see ResponseException HttpStatusCode 200...299
  * @see RequestParamsException HttpStatusCode 400...499
  * @see ServerResponseException HttpStatusCode 500...599

+ 1 - 1
net/src/main/java/com/drake/net/exception/NetCancellationException.kt

@@ -35,7 +35,7 @@ class NetCancellationException(
 
 
 /**
- * 抛出该异常将取消作用域内所有的网络请求
+ * 在作用域中抛出该异常将取消作用域内所有的网络请求(如果存在的话)
  */
 @Suppress("FunctionName")
 fun CoroutineScope.NetCancellationException(message: String? = null): NetCancellationException {

+ 6 - 0
net/src/main/java/com/drake/net/exception/NetConnectException.kt

@@ -2,6 +2,12 @@ package com.drake.net.exception
 
 import okhttp3.Request
 
+/**
+ * 连接错误
+ * @param request 请求信息
+ * @param message 错误描述信息
+ * @param cause 错误原因
+ */
 class NetConnectException(
     request: Request,
     message: String? = null,

+ 5 - 2
net/src/main/java/com/drake/net/exception/NetException.kt

@@ -21,8 +21,11 @@ import java.io.IOException
 
 
 /**
- * Net网络异常
- * @param message 异常信息
+ * 表示为Net发生的网络异常
+ * 在转换器[com.drake.net.convert.NetConverter]中抛出的异常如果没有继承该类都会被视为数据转换异常[ConvertException], 该类一般用于自定义异常
+ * @param request 请求信息
+ * @param message 错误描述信息
+ * @param cause 错误原因
  */
 open class NetException(
     open val request: Request,

+ 6 - 0
net/src/main/java/com/drake/net/exception/NetSocketTimeoutException.kt

@@ -2,6 +2,12 @@ package com.drake.net.exception
 
 import okhttp3.Request
 
+/**
+ * 请求过程中读取或者写入超时
+ * @param request 请求信息
+ * @param message 错误描述信息
+ * @param cause 错误原因
+ */
 class NetSocketTimeoutException(
     request: Request,
     message: String? = null,

+ 6 - 0
net/src/main/java/com/drake/net/exception/NetUnknownHostException.kt

@@ -2,6 +2,12 @@ package com.drake.net.exception
 
 import okhttp3.Request
 
+/**
+ * 主机域名无法访问
+ * @param request 请求信息
+ * @param message 错误描述信息
+ * @param cause 错误原因
+ */
 class NetUnknownHostException(
     request: Request,
     message: String? = null,

+ 3 - 0
net/src/main/java/com/drake/net/exception/NoCacheException.kt

@@ -2,6 +2,9 @@ package com.drake.net.exception
 
 import okhttp3.Request
 
+/**
+ * 该异常暂未实现, 属于保留异常
+ */
 class NoCacheException(
     request: Request,
     message: String? = null,

+ 4 - 0
net/src/main/java/com/drake/net/exception/RequestParamsException.kt

@@ -20,6 +20,10 @@ import okhttp3.Response
 
 /**
  * 400 - 499 客户端请求异常
+ * @param response 响应信息
+ * @param message 错误描述信息
+ * @param cause 错误原因
+ * @param tag 可携带任意对象, 一般用于在转换器/拦截器中添加然后传递给错误处理器去使用判断
  */
 class RequestParamsException(
     response: Response,

+ 7 - 1
net/src/main/java/com/drake/net/exception/ResponseException.kt

@@ -20,7 +20,13 @@ package com.drake.net.exception
 
 import okhttp3.Response
 
-/** 状态码在200..299, 但是返回数据不符合业务要求可以抛出该异常 */
+/**
+ * 状态码在200..299, 但是返回数据不符合业务要求可以抛出该异常
+ * @param response 响应信息
+ * @param message 错误描述信息
+ * @param cause 错误原因
+ * @param tag 可携带任意对象, 一般用于在转换器/拦截器中添加然后传递给错误处理器去使用判断
+ */
 class ResponseException(
     response: Response,
     message: String? = null,

+ 4 - 0
net/src/main/java/com/drake/net/exception/ServerResponseException.kt

@@ -21,6 +21,10 @@ import okhttp3.Response
 
 /**
  * >= 500 服务器异常
+ * @param response 响应信息
+ * @param message 错误描述信息
+ * @param cause 错误原因
+ * @param tag 可携带任意对象, 一般用于在转换器/拦截器中添加然后传递给错误处理器去使用判断
  */
 class ServerResponseException(
     response: Response,

+ 3 - 0
net/src/main/java/com/drake/net/exception/URLParseException.kt

@@ -2,6 +2,9 @@ package com.drake.net.exception
 
 /**
  * URL地址错误
+ *
+ * @param message 错误描述信息
+ * @param cause 错误原因
  */
 open class URLParseException(
     message: String? = null,