Hei, I get the following error when trying to defi...
# http4k
c
Hei, I get the following error when trying to define a endpoint that starts with a dynamic path. (Example:
Path.of("system", "The target system ") / "/feed"
.
Exception in thread "main" java.lang.IllegalArgumentException: Fixed path segments cannot contain /. Use the "a / b" form.
Any ideas?
d
you don't need the prefixing /
c
Path.of(“system”, “The target system “) / “feed”
?
d
yep
c
still the same error
Copy code
return  Path.of("system", "The target system ") / "feed" meta {
d
Hmmm. Can you stick it in a gist please?
c
I think i figure out where the problem is. In my code the static path is composed of 2 elements. Something like return Path.of(“system”, “The target system “) / “weather/feed” meta {
I think it does not like the “/” between weather and feed
Could this be it?
How would you define the endpoint in this case?
d
Aha - yes. You would use Path.of(“weather”) / “feed”
With suffix “strings” the bound handler function then takes 2 args- one of them is always “feed”.
Limitation of how it’s written I’m afraid
(And the type system)
c
but if both weather and feed are static
then i still have to write
Path.of(“weather”) / “feed”
d
Aha - then “weather” / “feed”
c
aha ok
thank you, will try
d
Or if that doesn’t work Path.fixed(“weather”) / “fixed “
(Haven’t got api in front of me)
c
👍 will try both
thank you
d
👍
c
Worked with Path.fixed but the in the HttpHandler i have to have all the paths as inputs
so for example getfeed(weatherPath: String): HttpHandler
d
Yep.
It’s because the path lens is basically matching on the input string.
Kotlin type system isn’t really powerful enough for what we’d ideally like.. 🙄