https://kotlinlang.org logo
Title
a

alieksie

12/18/2018, 1:56 PM
Hi http4k! Is it possible to have optional path segment? Like:
"/bar/" / Path.string().of(name = "foo")
comes
"/bar/" / Path.string().of(name = "foo").optional
So it would match both
/bar/foo
and
/bar/
r

reik.schatz

12/18/2018, 2:00 PM
you could create 2 routes or?
d

dave

12/18/2018, 2:01 PM
yeah - there isn't the concept of an optional path param - you can map the same handler to both routes though
a

alieksie

12/18/2018, 2:03 PM
thanks, i will go with 2 routes option then!
r

reik.schatz

12/18/2018, 2:03 PM
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

alieksie

12/18/2018, 2:04 PM
Thank you @reik.schatz