Hi http4k! Is it possible to have optional path se...
# http4k
a
Hi http4k! Is it possible to have optional path segment? Like:
Copy code
"/bar/" / Path.string().of(name = "foo")
comes
Copy code
"/bar/" / Path.string().of(name = "foo").optional
So it would match both
/bar/foo
and
/bar/
r
you could create 2 routes or?
d
yeah - there isn't the concept of an optional path param - you can map the same handler to both routes though
a
thanks, i will go with 2 routes option then!
r
Copy code
fun execute() { execute(null) }
fun execute(name: String?)

"/match/" bindContract Method.GET to ::execute
"/match/" / Path.string().of(name = "foo") bindContract Method.GET to ::execute
something along these lines 🙂
a
Thank you @reik.schatz