From 8871b58c75e2e82b75e677554606a48e648921dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihat=20Gu=CC=88ndu=CC=88z?= Date: Wed, 28 Jun 2017 07:46:42 +0200 Subject: [PATCH] Add default encoding option for simpler code See the following comment for rationale: https://github.com/Moya/Moya/issues/1135#issuecomment-310926082 --- Sources/Moya/TargetType.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sources/Moya/TargetType.swift b/Sources/Moya/TargetType.swift index 27efaec04..b7f35ee01 100644 --- a/Sources/Moya/TargetType.swift +++ b/Sources/Moya/TargetType.swift @@ -12,6 +12,9 @@ public protocol TargetType { /// The HTTP method used in the request. var method: Moya.Method { get } + /// The default parameterEncoding for the `.encoded` RequestDataType case. + var defaultParameterEncoding: ParameterEncoding { get } + /// Provides stub data for use in testing. var sampleData: Data { get } @@ -26,6 +29,10 @@ public protocol TargetType { } public extension TargetType { + var defaultParameterEncoding: ParameterEncoding { + return URLEncoding.default + } + var validate: Bool { return false }