Skip to content

Commit

Permalink
Add missing http methods (#8)
Browse files Browse the repository at this point in the history
## Description
As per the title.

## Related Issue
Closes #6
  • Loading branch information
martin-e91 authored Feb 25, 2024
1 parent d3a11d0 commit 28bac49
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 12 deletions.
10 changes: 0 additions & 10 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
---
name: Pull request
about: Create a pull request to contribute to this project
title: ""
labels: enhancement

---

# Pull Request

## Description
<!-- Briefly describe the changes introduced by this pull request. -->

Expand Down
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ let package = Package(
.target(name: "NetworkAPI"),
.target(name: "Network", dependencies: ["NetworkAPI"]),
.target(name: "NetworkMocks", dependencies: ["NetworkAPI"]),
.testTarget(name: "NetworkAPITests", dependencies: ["NetworkAPI"]),
.testTarget(name: "NetworkTests", dependencies: ["Network", "NetworkMocks"])
],
swiftLanguageVersions: [.v5]
Expand Down
21 changes: 19 additions & 2 deletions Sources/NetworkAPI/HTTPMethod.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
import Foundation

/// Method of an HTTP request.
/// The source of a request's semantics.
///
///[Reference](https://www.rfc-editor.org/rfc/rfc9110.html#name-methods).
public enum HTTPMethod: String {
case get = "GET"
/// Transfer a current representation of the target resource.
case get = "GET"
/// Same as GET, but do not transfer the response content.
case head = "HEAD"
/// Perform resource-specific processing on the request content.
case post = "POST"
/// Replace all current representations of the target resource with the request content.
case put = "PUT"
/// Remove all current representations of the target resource.
case delete = "DELETE"
/// Establish a tunnel to the server identified by the target resource.
case connect = "CONNECT"
/// Describe the communication options for the target resource.
case options = "OPTIONS"
/// Perform a message loop-back test along the path to the target resource.
case trace = "TRACE"
}
15 changes: 15 additions & 0 deletions Tests/NetworkAPITests/HTTPMethodTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import NetworkAPI
import XCTest

final class HTTPMethodTests: XCTestCase {
func testRawValue_whenCalled_shouldReturnExpectedValue() {
XCTAssertEqual(HTTPMethod.get.rawValue, "GET")
XCTAssertEqual(HTTPMethod.head.rawValue, "HEAD")
XCTAssertEqual(HTTPMethod.post.rawValue, "POST")
XCTAssertEqual(HTTPMethod.put.rawValue, "PUT")
XCTAssertEqual(HTTPMethod.delete.rawValue, "DELETE")
XCTAssertEqual(HTTPMethod.connect.rawValue, "CONNECT")
XCTAssertEqual(HTTPMethod.options.rawValue, "OPTIONS")
XCTAssertEqual(HTTPMethod.trace.rawValue, "TRACE")
}
}

0 comments on commit 28bac49

Please sign in to comment.