0

I am trying to handle a request containing word "filter". For the time being, I am using the url as http://localhost:9997/filter=....

and parsing by using pathPrefix(fiter)

But url will change and becomes like http://localhost:9997/something../filter=

So here I can't take pathPrefix(). How can I handle this kind of path in routing so that any url containing "filter" keyword it can handle. I am very much new to akka spray. Please let me know about your opinions. Thanks in advance

user1548787
  • 101
  • 1
  • 1
  • 8
  • Please let me know how can I work on this issue. All yours suggestions will be appreciated and helpful to fix this issue. Any example or materials will be good.Thanks. – user1548787 Mar 28 '16 at 12:12

1 Answers1

0

If the string you want to match will always be at the end you can use "pathSuffix" (it might be enough for what you want)

pathSuffix("filter") { ... }

But if it can be anywhere in the path, is not that straighforward. One way is using segments:

path( Segment / "filter" / Segment ){ (prefix, postfix) => {...} }

But it doesn't match if filter is at either end: "filter/blah/blah" nor "balh/blah/filter", but you can work around by matching with prefix and suffix. I suppose there's a better way, maybe with a custom directive.

Take a look at http://spray.io/documentation/1.2.3/spray-routing/predefined-directives-alphabetically/#predefined-directives

GClaramunt
  • 3,148
  • 1
  • 21
  • 35