HTTP

enum HTTP

Simple HTTP library

  • Request with compleation handler with error handeling

    Declaration

    Swift

    static func request(method: Method = .GET, url: URL, body: Data? = nil,
                        additionalHeaders headers: [String: String] = [:],
                        completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void)
  • Request with compleation handler without error handeling

    Declaration

    Swift

    static func request(method: Method = .GET, url: URL, body: Data? = nil,
                        additionalHeaders headers: [String: String] = [:],
                        completionHandler: @escaping (Data) -> Void)
  • Request without compleation handler

    Declaration

    Swift

    static func request(method: Method = .GET, url: URL, body: Data? = nil,
                        additionalHeaders headers: [String: String] = [:])
  • Encodes data as JSON and post json to url, with appropiate headers.

    Declaration

    Swift

    static func post<POSTDATA: Encodable>(asJSON data: POSTDATA, to url: URL,
                                          completionHandler: @escaping (Data) -> Void)