@@ -18,13 +18,13 @@ public class ATRequest {
1818 var body : Data ?
1919 var task : URLSessionTask ?
2020
21- var contentType : ContentType = . applicationJson {
21+ public var contentType : ContentType = . applicationJson {
2222 didSet {
2323 self . headers [ " Content-Type " ] = self . contentType. rawValue
2424 }
2525 }
2626
27- enum ContentType : String {
27+ public enum ContentType : String {
2828 case applicationJson = " application/json "
2929 case textPlain = " text/plain "
3030 case textHtml = " text/html "
@@ -40,6 +40,7 @@ public class ATRequest {
4040 let result = ATRequest ( )
4141 result. url = url
4242 result. method = method
43+ result. headers = ATRequest . Configuration. defaultHeaders
4344 return result
4445 }
4546
@@ -49,7 +50,7 @@ public class ATRequest {
4950 }
5051
5152 @discardableResult public func setJsonBody( body: JSONObject ) -> Self {
52- self . body = body. toJsonData ( )
53+ self . body = Configuration . parametersCreator ( body) . toJsonData ( )
5354 self . contentType = . applicationJson
5455 return self
5556 }
@@ -79,4 +80,9 @@ public class ATRequest {
7980 responseHandler ? ( atResponse)
8081 }
8182 }
83+
84+ public class Configuration {
85+ public static var defaultHeaders : [ String : String ] = [ : ]
86+ public static var parametersCreator : ( JSONObject ) -> JSONObject = { input in return input}
87+ }
8288}
0 commit comments