Skip to content

Commit

Permalink
Making URL's optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Sargent committed Sep 22, 2016
1 parent eee8988 commit 98448f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion LKAPI.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = "LKAPI"
s.version = "1.2.0"
s.version = "1.2.1"
s.summary = "Wrapper around Alamofire"
s.description = "Wrapper built around Alamofire to make working with APIs easier"
s.homepage = "https://github.com/Lightningkite/LKAPI"
Expand Down
8 changes: 6 additions & 2 deletions Pod/Classes/API.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Alamofire


///Successful request callback
public typealias successCallback = ((AnyObject?) -> ())
public typealias successCallback = ((Any?) -> ())
///Failed request callback
public typealias failureCallback = ((Failure) -> ())
///Represents a header for a request
Expand Down Expand Up @@ -110,7 +110,7 @@ public protocol Routable: URLRequestConvertible {
var method: Alamofire.HTTPMethod { get }

///Path to the endpoint
var path: URL { get }
var path: URL? { get }

///Optional parameters to send up in the body of each request
var parameters: ModelDict? { get }
Expand All @@ -129,6 +129,10 @@ public protocol Routable: URLRequestConvertible {
public extension Routable {
///URLRequest object
public func asURLRequest() throws -> URLRequest {
guard let path = path else {
throw AFError.invalidURL(url: "")
}

var request = URLRequest(url: path)
request.httpMethod = method.rawValue

Expand Down

0 comments on commit 98448f7

Please sign in to comment.