탐색 메인 페이지

This commit is contained in:
Yu Sung
2023-08-10 13:01:16 +09:00
parent f8bab4c232
commit 943e1d9f7f
10 changed files with 434 additions and 1 deletions

View File

@@ -0,0 +1,51 @@
//
// ExplorerApi.swift
// SodaLive
//
// Created by klaus on 2023/08/10.
//
import Foundation
import Moya
enum ExplorerApi {
case getExplorer
case searchChannel(channel: String)
}
extension ExplorerApi: TargetType {
var baseURL: URL {
return URL(string: BASE_URL)!
}
var path: String {
switch self {
case .getExplorer:
return "/explorer"
case .searchChannel:
return "/explorer/search/channel"
}
}
var method: Moya.Method {
switch self {
case .getExplorer, .searchChannel:
return .get
}
}
var task: Task {
switch self {
case .getExplorer:
return .requestPlain
case .searchChannel(let channel):
return .requestParameters(parameters: ["channel" : channel], encoding: URLEncoding.queryString)
}
}
var headers: [String : String]? {
return ["Authorization": "Bearer \(UserDefaults.string(forKey: UserDefaultsKey.token))"]
}
}