Replies: 1 comment
-
I think the tool for this is the enum FooRoute {
case assigned(Int)
}
struct FooRouter: ParserPrinter {
var body: some Router<FooRoute> {
OneOf {
Route(.case(FooRoute.assigned)) {
Path {
"optionalPath".replaceError(with: ())
Digits()
"assigned"
}
}
}
}
} |
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.
-
Our backend has a lot of different URLs that represent the same thing, so my parsers end up kind of bloated. I often end up with something like
My problems really tend to arise when I have an optional path component. So in addition to the above
OneOf
I may have part of the path that may or may not existWhich should be equivalent. I can solve something like this with separate parsers, but due to the bloating of URLs this can result in a lot of different parsers and reduces maintainability. Is there a way to effectively handle the case where I have an optional path parameter succinctly?
Beta Was this translation helpful? Give feedback.
All reactions