Method is set through enum value instead of string
This commit is contained in:
@@ -65,7 +65,7 @@ public struct Client {
|
||||
}
|
||||
|
||||
var urlRequest = URLRequest(url: url)
|
||||
urlRequest.httpMethod = request.method
|
||||
urlRequest.httpMethod = request.method.rawValue
|
||||
urlRequest.allHTTPHeaderFields = headers
|
||||
return urlRequest
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// RequestMethod.swift
|
||||
// JellyKit
|
||||
//
|
||||
// Created by Alex Loren on 10/19/26.
|
||||
//
|
||||
|
||||
/// What method should be used when sending a `Request` to Emby or Jellyfin.
|
||||
/// Usage of this enum prevents any chance of misspelling the method.
|
||||
public enum RequestMethod: String {
|
||||
case get = "GET"
|
||||
case head = "HEAD"
|
||||
case post = "POST"
|
||||
case delete = "DELETE"
|
||||
}
|
||||
@@ -14,7 +14,7 @@ protocol Request {
|
||||
var endpoint: String { get set }
|
||||
|
||||
/// What should this request be sent as?
|
||||
var method: String { get set }
|
||||
var method: RequestMethod { get set }
|
||||
|
||||
/// Any additional headers that are specific to *this* request.
|
||||
/// Headers needed for every reqeust should be set at `Client` creation.
|
||||
|
||||
@@ -11,6 +11,6 @@
|
||||
struct PingRequest: Request {
|
||||
// MARK: - Properties
|
||||
var endpoint: String = "/System/Ping"
|
||||
var method: String = "GET"
|
||||
var method: RequestMethod = .get
|
||||
var headers: [String : String]? = nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user