borchero / Squid

Declarative and Reactive Networking for Swift.

Home Page:https://squid.borchero.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to see response headers

AAAstorga opened this issue · comments

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!

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?

Sounds great to me!