Skip to content

Commit

Permalink
Type-erased protocol added.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugene committed Sep 30, 2021
1 parent 67e23b9 commit b47c2b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 10 additions & 0 deletions Sources/Endpoints/Endpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,13 @@ public struct EmptyBody: HTTPPayload {
extension String: HTTPPayload {
public var kind: HTTP.ContentType { .plainText }
}

// MARK: - AnyEndpoint

/// Type-erased Endpoint.
protocol AnyEndpoint: Endpoint { }

extension AnyEndpoint {

var body: EmptyBody? { nil }
}
4 changes: 1 addition & 3 deletions Tests/EndpointsTests/EndpointsTests.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import XCTest
@testable import Endpoints

struct GetAPI: Endpoint {
struct GetAPI: AnyEndpoint {

var method: HTTP.Method { .get }

Expand All @@ -13,8 +13,6 @@ struct GetAPI: Endpoint {

@HTTP.Parameter(name: "item-id", help: "item id")
var itemId: String

var body: EmptyBody?
}


Expand Down

0 comments on commit b47c2b7

Please sign in to comment.