Reputation: 838
This works:
rawPathPrefix("Ad(" ~ LongNumber ~ ")") { id =>
id
is now a Long
, but this doesn't work:
rawPathPrefix("Ad(" ~ String ~ ")") { id =>
id
is now a RequestContext
, not a String
?
Upvotes: 1
Views: 921
Reputation: 19517
One approach is to use a regex pattern that captures one or more characters between Ad(
and )
in the path prefix:
pathPrefix("""Ad\((.+)\)""".r) { id =>
...
}
For example, id
is the string "12-34b"
for a request sent to:
http://host:port/Ad(12-34b)
Upvotes: 2
Reputation: 1154
You need to use Segment.
path("hello"/Segment)
Check this: https://doc.akka.io/docs/akka-http/current/routing-dsl/path-matchers.html#examples
Upvotes: -1