Просмотр исходного кода

Update Usage.md Documentation (#2895)

* Start refactoring Usage document.

* Bit of work.

* Parameter encoding docs.

* Prep for merge.

* Start refactoring Usage document.

* Bit of work.

* Parameter encoding docs.

* Prep for merge.

* Finish parameter update.

* Header and start response docs.

* Finish updating DataRequest APIs.

* Update Download and Upload sections.

* Fix misspelling, cURL example.

* Update some styling.

* Break up long line.

* More styling.

* Additional styling.

* Update code snippet.

* Remove unnecessary note.

* Update a few bits of styling.

* Clean up headers whitespace.

* Update for HTTP method changes.

* Update docs for AF types, styling updates.

* Add index.

* Update ToC.

* Update README.

* Update note for mutiple handlers.

* Remove parens from closure capture examples.

* Usage Documentation Updates - cnoon Edits (#2929)

* Small updates and edits to the Usage documentation

* Removed unnecessary comma addition in array parameter encoding section
Jon Shier 6 лет назад
Родитель
Сommit
538edbfb89
4 измененных файлов с 486 добавлено и 323 удалено
  1. 471 315
      Documentation/Usage.md
  2. 4 5
      README.md
  3. 10 2
      Source/HTTPHeaders.swift
  4. 1 1
      Source/ParameterEncoder.swift

Разница между файлами не показана из-за своего большого размера
+ 471 - 315
Documentation/Usage.md


+ 4 - 5
README.md

@@ -18,9 +18,9 @@ Alamofire is an HTTP networking library written in Swift.
 - [Migration Guides](#migration-guides)
 - [Communication](#communication)
 - [Installation](#installation)
-- [Usage](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md)
-    - **Intro -** [Making a Request](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#making-a-request), [Response Handling](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#response-handling), [Response Validation](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#response-validation), [Response Caching](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#response-caching)
-	- **HTTP -** [HTTP Methods](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#http-methods), [Parameter Encoding](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#parameter-encoding), [HTTP Headers](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#http-headers), [Authentication](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#authentication)
+- [Usage](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#using-alamofire)
+    - [**Introduction -**](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#introduction) [Making Requests](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#making-requests), [Response Handling](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#response-handling), [Response Validation](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#response-validation), [Response Caching](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#response-caching)
+	- **HTTP -** [HTTP Methods](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#http-methods), [Parameters and Parameter Encoder](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md##request-parameters-and-parameter-encoders), [HTTP Headers](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#http-headers), [Authentication](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#authentication)
 	- **Large Data -** [Downloading Data to a File](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#downloading-data-to-a-file), [Uploading Data to a Server](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#uploading-data-to-a-server)
 	- **Tools -** [Statistical Metrics](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#statistical-metrics), [cURL Command Output](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#curl-command-output)
 - [Advanced Usage](https://github.com/Alamofire/Alamofire/blob/master/Documentation/AdvancedUsage.md)
@@ -104,8 +104,6 @@ The [Swift Package Manager](https://swift.org/package-manager/) is a tool for au
 
 Once you have your Swift package set up, adding Alamofire as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`.
 
-#### Swift 4
-
 ```swift
 dependencies: [
     .package(url: "https://github.com/Alamofire/Alamofire.git", from: "5.0.0-beta.5")
@@ -166,6 +164,7 @@ The following radars have been resolved over time after being filed against the
   - (Resolved): 9/1/17 in Xcode 9 beta 6.
 - [`rdar://36082113`](http://openradar.appspot.com/radar?id=4942308441063424) - `URLSessionTaskMetrics` failing to link on watchOS 3.0+
   - (Resolved): Just add `CFNetwork` to your linked frameworks.
+  
 ## FAQ
 
 ### What's the origin of the name Alamofire?

+ 10 - 2
Source/HTTPHeaders.swift

@@ -213,6 +213,14 @@ extension HTTPHeader: CustomStringConvertible {
 }
 
 extension HTTPHeader {
+    /// Returns an `Accept` header.
+    ///
+    /// - Parameter value: The `Accept` value.
+    /// - Returns:         The header.
+    public static func accept(_ value: String) -> HTTPHeader {
+        return HTTPHeader(name: "Accept", value: value)
+    }
+
     /// Returns an `Accept-Charset` header.
     ///
     /// - Parameter value: The `Accept-Charset` value.
@@ -270,7 +278,7 @@ extension HTTPHeader {
     /// Returns an `Authorization` header.
     ///
     /// Alamofire provides built-in methods to produce `Authorization` headers. For a Basic `Authorization` header use
-    /// `HTTPHeader.authorization(username: password:)`. For a Bearer `Authorization` header, use
+    /// `HTTPHeader.authorization(username:password:)`. For a Bearer `Authorization` header, use
     /// `HTTPHeader.authorization(bearerToken:)`.
     ///
     /// - Parameter value: The `Authorization` value.
@@ -291,7 +299,7 @@ extension HTTPHeader {
 
     /// Returns a `Content-Type` header.
     ///
-    /// All Alamofire `ParameterEncoding`s set the `Content-Type` of the request, so it may not be necessary to manually
+    /// All Alamofire `ParameterEncoding`s and `ParameterEncoder`s set the `Content-Type` of the request, so it may not be necessary to manually
     /// set this value.
     ///
     /// - Parameter value: The `Content-Type` value.

+ 1 - 1
Source/ParameterEncoder.swift

@@ -154,7 +154,7 @@ open class URLEncodedFormParameterEncoder: ParameterEncoder {
         }
 
         guard let method = request.method else {
-            let rawValue = request.httpMethod ?? "nil"
+            let rawValue = request.method?.rawValue ?? "nil"
             throw AFError.parameterEncoderFailed(reason: .missingRequiredComponent(.httpMethod(rawValue: rawValue)))
         }
 

Некоторые файлы не были показаны из-за большого количества измененных файлов