Skip to content

Commit e0c1691

Browse files
Yasumotoweissi
authored andcommitted
Small README fixes (#26)
* Small README fixes * Single backticks and no deinit
1 parent 23dd984 commit e0c1691

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Add the following entry in your <code>Package.swift</code> to start using <code>
2323
// it's early days here so we haven't tagged a version yet, but will soon
2424
.package(url: "https://github.com/swift-server/swift-nio-http-client.git", .branch("master"))
2525
```
26-
and ```NIOHTTPClient``` dependency to your target:
26+
and `NIOHTTPClient` dependency to your target:
2727
```swift
2828
.target(name: "MyApp", dependencies: ["NIOHTTPClient"]),
2929
```
@@ -49,19 +49,19 @@ httpClient.get(url: "https://swift.org").whenComplete { result in
4949
}
5050
```
5151

52-
It is important to close client instance after use to cleanly shutdown underlying NIO ```EventLoopGroup```:
53-
```
52+
It is important to close the client instance, for example in a `defer` statement, after use to cleanly shutdown the underlying NIO `EventLoopGroup`:
53+
```swift
5454
try? httpClient.syncShutdown()
5555
```
56-
Alternatively, you can provide shared ```EventLoopGroup```:
56+
Alternatively, you can provide shared `EventLoopGroup`:
5757
```swift
5858
let httpClient = HTTPClient(eventLoopGroupProvider: .shared(userProvidedGroup))
5959
```
6060
In this case shutdown of the client is not neccecary.
6161

6262
## Usage guide
6363

64-
Most common HTTP methods are supported out of the box. In case you need to have more control over the method, or you want to add headers or body, use ```HTTPRequest``` struct:
64+
Most common HTTP methods are supported out of the box. In case you need to have more control over the method, or you want to add headers or body, use the `HTTPRequest` struct:
6565
```swift
6666
import NIOHTTPClient
6767

@@ -70,7 +70,7 @@ defer {
7070
try? httpClient.syncShutdown()
7171
}
7272

73-
var request = try HTTPRequest(url: "https://swift.org", method: .POST)
73+
var request = try HTTPClient.HTTPRequest(url: "https://swift.org", method: .POST)
7474
request.headers.add(name: "User-Agent", value: "Swift HTTPClient")
7575
request.body = .string("some-body")
7676

@@ -98,13 +98,13 @@ let httpClient = HTTPClient(eventLoopGroupProvider: .createNew,
9898
### Timeouts
9999
Timeouts (connect and read) can also be set using the client configuration:
100100
```swift
101-
let timeout = Timeout(connectTimeout: .seconds(1), readTimeout: .seconds(1))
101+
let timeout = HTTPClient.Timeout(connect: .seconds(1), read: .seconds(1))
102102
let httpClient = HTTPClient(eventLoopGroupProvider: .createNew,
103103
configuration: HTTPClient.Configuration(timeout: timeout))
104104
```
105-
or on per-request basis:
105+
or on a per-request basis:
106106
```swift
107-
let timeout = Timeout(connectTimeout: .seconds(1), readTimeout: .seconds(1))
107+
let timeout = HTTPClient.Timeout(connect: .seconds(1), read: .seconds(1))
108108
httpClient.execute(request: request, timeout: timeout)
109109
```
110110

@@ -115,7 +115,7 @@ class CountingDelegate: HTTPResponseDelegate {
115115
typealias Response = Int
116116

117117
var count = 0
118-
118+
119119
func didTransmitRequestBody() {
120120
// this is executed when request is sent, called once
121121
}
@@ -130,10 +130,11 @@ class CountingDelegate: HTTPResponseDelegate {
130130
}
131131

132132
func didFinishRequest() throws -> Int {
133-
// this is called when request is fully read, called once, this is where you return a result or throw any errors you require to propagate to the client
133+
// this is called when the request is fully read, called once
134+
// this is where you return a result or throw any errors you require to propagate to the client
134135
return count
135136
}
136-
137+
137138
func didReceiveError(_ error: Error) {
138139
// this is called when we receive any network-related error, called once
139140
}

0 commit comments

Comments
 (0)