-
Hi, I need some help on printing a url from my route. enum AppRoute {
case foo(String)
}
let router = OneOf {
Route(AppRoute.foo) {
Path {
"foo"
Parse(.string)
}
}
}
guard let url = URLRequest(
data: try router
.baseURL("https://my-host.app")
.print(.foo("barbaz"))
)?.url else { return } With the code above, I get the following compilation error: How can I get this to compile? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
I am not sure it will help you or not try check lib tests |
Beta Was this translation helpful? Give feedback.
-
Unfortunately no. The samples there are too simple. They don't use a route with associated value. Without the associated string the compiler is happy. But I need that value. |
Beta Was this translation helpful? Give feedback.
-
You need to add the enum TestRoute {
case foo(String)
}
let theRouter = OneOf {
Route(.case(TestRoute.foo)) {
Path {
"foo"
Parse(.string)
}
}
}
let url = try theRouter
.baseURL("https://my-host.app")
.url(for: .foo("1234")) |
Beta Was this translation helpful? Give feedback.
You need to add the
.case
in the router to make it a ParserPrinter: