Skip to content

Instantly share code, notes, and snippets.

@fmo91
Last active February 12, 2017 05:30
Show Gist options
  • Save fmo91/66bca796843d1439ad197e96fd9adfc8 to your computer and use it in GitHub Desktop.
Save fmo91/66bca796843d1439ad197e96fd9adfc8 to your computer and use it in GitHub Desktop.
Sample implementation of a network Request
//
// Request.swift
//
// Created by Fernando Ortiz on 2/12/17.
//
import Foundation
enum HTTPMethod: String {
case get, post, put, patch, delete
}
protocol Request {
var path : String { get }
var method : HTTPMethod { get }
var bodyParams : [String: Any]? { get }
var headers : [String: String]? { get }
}
extension Request {
var method : HTTPMethod { return .get }
var bodyParams : [String: Any]? { return nil }
var headers : [String: String]? { return nil }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment