Skip to content

Commit

Permalink
Merge pull request #11 from mehdiimrz/update-readme
Browse files Browse the repository at this point in the history
update readme
  • Loading branch information
mehdiimrz authored Jan 10, 2022
2 parents 576b67e + 075d8dc commit 90c57f5
Showing 1 changed file with 33 additions and 11 deletions.
44 changes: 33 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,36 @@ NetShears adds a Request interceptor mechanisms to be able to modify the HTTP/HT
- [x] Intercept HTTP/HTTPS request header
- [x] Intercept HTTP/HTTPS request endpoint
- [x] View traffic logs
- [x] Request obserever
- [ ] Intercept HTTP/HTTPS response body
- [ ] Block HTTP requets

## How it works

NetShears working by swizzling the URLProtocol.


## How to use
Start NetShears by calling ```startRecording()``` in didFinishLaunchingWithOptions
NetShears has three main functionality :

1 - Network request observer which can be used to observe every HTTP/HTTPS request using delegation.
```swift
import NetShears

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
Netshears.shared.startListener()
```

NetShears.startRecording()
2 - Request interceptor mechanisms to be able to modify the HTTP/HTTPS Request before being sent.
```swift
Netshears.shared.startInterceptor()
```

}
3 - Show network traffics.
```swift
Netshears.shared.startLogger()
```

## Interceptor

Make sure to call ```startInterceptor()``` before adding modifiers.
```swift
Netshears.shared.startInterceptor()
```

Header Modification:

```swift
Expand All @@ -53,6 +60,11 @@ NetShears.shared.modify(modifier: endpointModifier)

# Traffic Monitoring

Make sure to call ```startLogger()``` before showing netwrok traffic logs.
```swift
Netshears.shared.startLogger()
```

In order to show network traffics in your app simply call presentNetworkMonitor method and then a view will present containing traffic logs.

```swift
Expand Down Expand Up @@ -99,6 +111,16 @@ func insertNote(note: Note, completion: @escaping(Note?, CallResult?) -> Void) {
}
```

# Request Observer

For observing requests you need to first call startListener then just simply adopt RequestBroadcast <RequestBroadcastDelegate> delegate.
```swift
NetShears.shared.startListener()

RequestBroadcast.shared.setDelegate(self)

```

## Installation

### [Swift Package Manager](https://github.com/apple/swift-package-manager)
Expand All @@ -113,7 +135,7 @@ import PackageDescription
let package = Package(
name: "YourProject",
dependencies: [
.package(url: "https://github.com/divar-ir/NetShears.git", from: "1.0.0"),
.package(url: "https://github.com/divar-ir/NetShears.git", from: "3.0.1"),
],
targets: [
.target(name: "YourProject", dependencies: ["NetShears"])
Expand Down

0 comments on commit 90c57f5

Please sign in to comment.