3lvis/Networking

Support custom request header fields

poprandi opened this issue · 3 comments

Having support for custom request headers would be great!
At the moment it's only possible to add an authenticate header. It should be possible to add multiple header parameters for a request.

Something like this:
public func POST(_ path: String, parameterType: Networking.Networking.ParameterType = default, headers: [String: Any]?, parameters: Any? = default, completion: @escaping (Any?, [AnyHashable : Any], NSError?) -> ()) -> String

The framework currently does not support to be extended, because the new access control from Swift 3, is not declared as open. (it should be 'open' instead of 'public')

Would it be possible to add these changes to the framework?

3lvis commented

Hi @poprandi,

Thanks for the suggestions, any particular headers that you might be interested about? Would be great to understand your use case to be able to provide better support for it.

Regarding subclassing, could you share your subclassing needs, please? Sounds like a good idea to make it open but I would prefer to avoid that unless is needed in order to push proposals to the repo so everybody gets the benefit instead of having everyone adding the same patches in their subclasses.

Hi @3lvis ,

thank you for your fast answer…
With custom headers I meant something like the following example:

let customHeaders = ["api-key": "abc123", "lang": "en", "version": 1.0]
networking.POST("/some/path", parameterType: .json, parameters: nil, headers: customHeaders) { (response, headers, error) in ...

with subclassing "Networking" I thought about… if someone would like to make a wrapper for some rest service (or sometimes it could also be, that the implementation requires more than one 3rd party service) that the whole networking/connectivity could be extended by adding reachability and other connectivity layer functionalities.

3lvis commented

Hi @poprandi

This might not fix your issue but I help it helps a bit: #143