ResponseModelRequest

public protocol ResponseModelRequest

响应模型请求协议

  • 关联响应模型数据类型,默认支持Any|AnyModel,可扩展

    Declaration

    Swift

    associatedtype ResponseModel
  • 当前响应模型,默认调用responseModelFilter

    Declaration

    Swift

    var responseModel: ResponseModel? { get set }
  • 解析响应模型方法

    Declaration

    Swift

    func responseModelFilter() -> ResponseModel?

Available where Self: HTTPRequest

  • responseModel Default implementation

    Default Implementation

    默认实现当前响应模型,解析成功时自动缓存

    Declaration

    Swift

    public var responseModel: ResponseModel? { get nonmutating set }
  • responseModelFilter() Default implementation

    Default Implementation

    默认实现解析响应模型方法,返回responseJSONObject

    Declaration

    Swift

    public func responseModelFilter() -> ResponseModel?
  • responseModel(_:) Extension method

    快捷设置模型响应成功句柄

    Declaration

    Swift

    @discardableResult
    public func responseModel(_ success: (@MainActor @Sendable (ResponseModel?) -> Void)?) -> Self
  • responseCacheModel(_:) Extension method

    解析缓存响应模型句柄,必须在start之前调用生效

    Declaration

    Swift

    @discardableResult
    public func responseCacheModel(_ success: (@MainActor @Sendable (ResponseModel?) -> Void)?) -> Self

Available where Self: HTTPRequest, ResponseModel: AnyModel

  • safeResponseModel Extension method

    默认实现当前安全响应模型

    Declaration

    Swift

    public var safeResponseModel: ResponseModel { get }
  • responseModelFilter() Default implementation

    Default Implementation

    默认实现解析响应模型方法,调用decodeResponseModel,具体路径为nil

    Declaration

    Swift

    public func responseModelFilter() -> ResponseModel?
  • 默认实现解析响应数据为数据模型,支持具体路径

    Declaration

    Swift

    public func decodeResponseModel(designatedPath: String? = nil) -> ResponseModel?
  • safeResponseModel(_:) Extension method

    快捷设置安全模型响应成功句柄

    Declaration

    Swift

    @discardableResult
    public func safeResponseModel(_ success: (@MainActor @Sendable (ResponseModel) -> Void)?) -> Self
  • responseSafeCacheModel(_:) Extension method

    解析缓存安全响应模型句柄,必须在start之前调用生效

    Declaration

    Swift

    @discardableResult
    public func responseSafeCacheModel(_ success: (@MainActor @Sendable (ResponseModel) -> Void)?) -> Self

Available where Self: HTTPRequest

  • responseModel() Extension method, asynchronous

    异步获取模型响应,注意非Task取消也会触发(Continuation流程)

    Declaration

    Swift

    public func responseModel() async throws -> ResponseModel? where Self.ResponseModel : Sendable

Available where Self: HTTPRequest, ResponseModel: AnyModel

  • safeResponseModel() Extension method, asynchronous

    异步获取安全模型响应,注意非Task取消也会触发(Continuation流程)

    Declaration

    Swift

    public func safeResponseModel() async throws -> ResponseModel where Self.ResponseModel : Sendable