borchero / Squid

Declarative and Reactive Networking for Swift.
https://squid.borchero.com
MIT License
71 stars 6 forks source link

How to see response headers #19

Closed AAAstorga closed 4 years ago

AAAstorga commented 4 years ago
import Squid
import Foundation

struct ListPlaylistsRequest: JsonRequest {
    typealias Result = [Playlist]

    var routes: HttpRoute {
        ["playlist", "v1"]
    }

    var method: HttpMethod {
        .get
    }
}

This request talks to my server and there are some headers that are returned from the request that I want to have access to. I tried using a ServiceHook but I don't think I get the response headers. Ideally I can still have it decoded automatically to JSON as well. I am not sure how to proceed. Love the library!

borchero commented 4 years ago

Thanks for the issue, in fact, receiving the header is currently not supported. It would probably be possible to overload the schedule(_:) method to return both the result type and the header as [String: String]. What do you think about that?

AAAstorga commented 4 years ago

Sounds great to me!

borchero commented 4 years ago

https://github.com/borchero/Squid/releases/tag/1.4.2