Skip to content

Latest commit

 

History

History
100 lines (67 loc) · 3.16 KB

README.md

File metadata and controls

100 lines (67 loc) · 3.16 KB

LightNetwork中文文档

Swift Platforms

LightNetwork is a very easy-write HTTP networking library written in Swift, depend on Alamofire

Features

  • All Alamofire Functions

  • Use a class method to initiate a request

  • Support base url, path

  • Add global parameters

  • Add global headers

  • Add global response

  • Intercept begin and end for all of request

  • Allow or deny request globally

  • Easy Example

Introduction

After the global configuration, you can easily initiate a request using LightNetwork.

    //Global Config
    var config = LNNetworkConfiguration(baseURL: URL(string: "http://example.com/"))
    LNNetworkManager.default.configuration = config

    //packaging
    class ExampleRequest : LNRequest {
        class func modify(userName:String,success: @escaping LNRequestSuccess, failure:@escaping LNRequestFailure) {
            self.post(path: "/modify", parameters: ["userName":userName], success: success, failure: failure)
        }
    }
    //use
    ExampleRequest.modify(userName: "Light") { request, responseData in
        print("Success:\(responseData)")
    } failure: { request, error in
        print("Failure:\(error)")
    }

Installation

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, adding LightNetwork as a dependency is as easy as adding it to the dependencies value of your Package.swift or the Package list in Xcode.

dependencies: [
    .package(url: "https://github.com/lengain/LightNetwork.git", .upToNextMajor(from: "1.0.0"))
]

Normally you'll want to depend on the LightNetwork target:

.product(name: "LightNetwork", package: "LightNetwork")

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate LightNetwork into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'LightNetwork'

Manually

If you prefer not to use any of the aforementioned dependency managers, you can integrate LightNetwork into your project manually.

Requirements

  • iOS 13.0+
  • macOS 10.15+
  • tvOS 12.0+
  • watchOS 4.0+
  • Swift 5.7.1
  • Xcode 14.1

License

LightNetwork is released under the MIT license. See LICENSE for details.