Swiftpack.co - brmaciel/NetworkKit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by brmaciel.
brmaciel/NetworkKit 1.0.0
NetworkKit is an HTTP networking library and is available to be used in any swift project.
⭐️ 1
🕓 30 weeks ago
.package(url: "https://github.com/brmaciel/NetworkKit.git", from: "1.0.0")


NetworkKit is an HTTP networking library.



  • RequestProtocol: this protocol has all parameters needed to be used to build the request.
  • HTTPMethod: enumeration that provides all http methods available.


  • NetworkResponse: this protocol has all information about the network response.
  • NetworkResponseResult: enumeration with possible network request results (success, failure).
  • NetworkResponseError: enumeration with possible network request errors. It is used to compose the network response result when it is a failure.


  • ResponseMapper: protocol that defines a response mapper. Response mappers are responsible for mapping a response instance (which is decoded from Data) into some model.
  • MainResponseMapper: a concrete class that implements the protocol. It must be inherited and its method .map(_:) should always be overriden.


  • ServiceProtocol: protocol that defines methods that should be implemented by a worker.
  • MainWorker: it's the main worker and responsible for all requests. It must be inherited and its subclasses should use one of its final methods to make requests and treat the response.
// Example
class ExampleWorker: MainWorker {
    func fetchExample() {
        makeRequest(request: ExampleRequest(),
                    mapResponseAction: ExampleMapper().map,
                    success: { model in
                    }, failure: { response in


  • BackendProvider: protocol that defines a backend provider. A backend provider is responsible for the receiving request parameters, treat them and make the request using some ApiRequester.
  • DefaultBackendProvider: it's an example of backend provider with a default implementation of how to treat the request parameters (header, body, http method, endpoint, path parameters, query parameters), build the request url and make the request using the DefaultApiRequester. Feel free to inherit this class or create your own backend provider from scratch.


  • ApiRequester: protocol that defines an api requester. The api requester is the actual component responsible for making the request and communicating to the api.
  • DefaultApiRequester: it's an example of api requester with a default implementation of making the request. Feel free to create your own api requester.


Stars: 1
Last commit: 3 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

Initial release
30 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics