mirror of
https://github.com/zhigang1992/swift-request.git
synced 2026-01-12 17:52:47 +08:00
Update the route parameter to resource
This commit is contained in:
committed by
Ailton Vieira
parent
30e1dccc88
commit
6c3e36fffe
@@ -4,7 +4,7 @@ public macro Service() = #externalMacro(module: "SwiftRequestMacros", type: "Ser
|
||||
|
||||
@attached(member, names: named(baseURL), named(session), named(init(baseURL:session:)))
|
||||
@attached(conformance)
|
||||
public macro Service(route: String) = #externalMacro(module: "SwiftRequestMacros", type: "ServiceMacro")
|
||||
public macro Service(resource: String) = #externalMacro(module: "SwiftRequestMacros", type: "ServiceMacro")
|
||||
|
||||
@attached(peer, names: overloaded)
|
||||
public macro GET<T: Decodable>(_ path: String, headers: [String: any CustomStringConvertible] = [:]) = #externalMacro(module: "SwiftRequestMacros", type: "GetRequestMacro")
|
||||
|
||||
@@ -9,10 +9,10 @@ public struct ServiceMacro: MemberMacro {
|
||||
in context: some MacroExpansionContext
|
||||
) throws -> [DeclSyntax] {
|
||||
let attribute = Attribute(from: node)
|
||||
let route = attribute.arguments.first?.value
|
||||
let resource = attribute.arguments.first?.value
|
||||
|
||||
let baseUrlExpr = if let route {
|
||||
"baseURL.appendingPathComponent(\"\(route)\")"
|
||||
let baseUrlExpr = if let resource {
|
||||
"baseURL.appendingPathComponent(\"\(resource)\")"
|
||||
} else {
|
||||
"baseURL"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user