Skip to content

Commit

Permalink
Rename Request.Parser to Request.DataParser
Browse files Browse the repository at this point in the history
(cherry picked from commit 3593a02)
  • Loading branch information
ishkawa authored and Econa77 committed Oct 22, 2022
1 parent 2e33919 commit 4142c14
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Sources/APIKit/Request.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
public protocol Request {
/// The response type associated with the request type.
associatedtype Response
associatedtype Parser: DataParser
associatedtype DataParser: APIKit.DataParser

/// The base URL.
var baseURL: URL { get }
Expand Down Expand Up @@ -41,7 +41,7 @@ public protocol Request {
var headerFields: [String: String] { get }

/// The parser object that states `Content-Type` to accept and parses response body.
var dataParser: Parser { get }
var dataParser: DataParser { get }

/// Intercepts `URLRequest` which is created by `Request.buildURLRequest()`. If an error is
/// thrown in this method, the result of `Session.send()` turns `.failure(.requestError(error))`.
Expand All @@ -53,12 +53,12 @@ public protocol Request {
/// The default implementation of this method is provided to throw `ResponseError.unacceptableStatusCode`
/// if the HTTP status code is not in `200..<300`.
/// - Throws: `Error`
func intercept(object: Parser.Parsed, urlResponse: HTTPURLResponse) throws -> Parser.Parsed
func intercept(object: DataParser.Parsed, urlResponse: HTTPURLResponse) throws -> DataParser.Parsed

/// Build `Response` instance from raw response object. This method is called after
/// `intercept(object:urlResponse:)` if it does not throw any error.
/// - Throws: `Error`
func response(from object: Parser.Parsed, urlResponse: HTTPURLResponse) throws -> Response
func response(from object: DataParser.Parsed, urlResponse: HTTPURLResponse) throws -> Response
}

public extension Request {
Expand Down Expand Up @@ -90,7 +90,7 @@ public extension Request {
return urlRequest
}

func intercept(object: Parser.Parsed, urlResponse: HTTPURLResponse) throws -> Parser.Parsed {
func intercept(object: DataParser.Parsed, urlResponse: HTTPURLResponse) throws -> DataParser.Parsed {
guard 200..<300 ~= urlResponse.statusCode else {
throw ResponseError.unacceptableStatusCode(urlResponse.statusCode)
}
Expand Down

0 comments on commit 4142c14

Please sign in to comment.