Route with Paths vs Fragment #88
GuilhermeMota93
started this conversation in
Show and tell
Replies: 1 comment
-
The library ships with a fragment parser. import URLRouting
enum FooRoute {
case pages(id: String, subsection: String?)
case deepPage(id: String, tab: String?)
}
struct FooRouter: ParserPrinter {
var body: some Router<FooRoute> {
OneOf {
Route(.case(FooRoute.pages)) {
Path { "pages"; Parse(.string) }
Optionally {
Fragment()
}
}
Route(.case(FooRoute.deepPage)) {
Path { "deepPage"; Parse(.string) }
Optionally {
Path { Parse(.string) }
}
}
}
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Had a need recently to support something else than Paths - so I stumbled upon the Fragment approach and thought I'd share
Beta Was this translation helpful? Give feedback.
All reactions