Git Product home page Git Product logo

networkxi's Introduction

NetworkXI

Exquisite networking package for iOS (version >= 13.0)


List of features

  • NetworkXI utilizes fundamental URLSession under the hood
  • NetworkXI exclusively takes advantage of Async/await approach for request making
  • All interactions with NetworkXI are based on protocols, so you can make your own implementations of NetworkSessionInterface, NetworkService
  • NetworkXI provides logger that prints beautifully crafted request/response events into Xcode console
  • NetworkXI provides the opportunity to renew session by updating authorization
  • NetworkXI supports SSL certificate pinning along with default challenge
  • NetworkXI supports easily implemented response mocking
  • NetworkXI supports response caching feature
  • NetworkXI supports separate implementation (WebSocketSessionInterface, WebSocketService) of web-socket message exchange

Example of use

Creating URL list

import NetworkXI

struct HttpbinOrgURL: RequestURLExtensible {

    let path: String
    var host: String { "httpbin.org" }
}

extension HttpbinOrgURL {

    static let uuid = Self("/uuid")
}

Describing request

import NetworkXI

class UUIDRequest: NetworkRequest {

    var url: RequestURL { HttpbinOrgURL.uuid }
    var method: RequestMethod { .GET }
    var encoding: RequestContentEncoding { .url }
}

Making the request

import NetworkXI

// Create session interface and use it across the app
let sessionAdapter = NetworkSessionAdapter()
sessionAdapter.defaultSSLChallengeEnabled = true

// Work with a new instance of network service
let worker = NetworkWorker(sessionInterface: sessionAdapter)

let request = UUIDRequest()
let response = await worker.make(request)

if response.success,
   let body = response.jsonBody,
   let uuidString = body["uuid"] as? String {
    print("UUID: " + uuidString)
}

License

NetworkXI is released under the MIT license

networkxi's People

Contributors

presscorp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

bankrbk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.