Closed earlgaspard closed 2 years ago
Related to #115? (using transformSuccess(_:)
, you should be able to go from Data
to an HTML String
or any custom struct that represents HTML)
Is that (using transformSuccess(_:)
) something Hyperspace does or something a user has to implement?
Hyperspace provides a default implementation of transformSuccess(_:)
when the request's ResponseType
conforms to Decodable
. The user would need to implement it for special scenarios like parsing errors from 200 OK
responses.
I'm going to close this one out - if the user is wanting to use a non-Decodable
type, they can use the following initializer on Request
, where they are free to convert TransportSuccess
into Response
in any way desired.
public init(method: HTTP.Method, url: URL, headers: [HTTP.HeaderKey: HTTP.HeaderValue]? = nil,
body: HTTP.Body? = nil, cachePolicy: URLRequest.CachePolicy = RequestDefaults.defaultCachePolicy,
timeout: TimeInterval = RequestDefaults.defaultTimeout, successTransformer: @escaping Transformer)
Implement a way for Hyperspace to handle non-JSON responses such as HTML