1

I have a base url of an API like this

http://host/api/categories

In my database categories are a tree based model. I'd like to be able to have an api where I can hit urls like

http://host/api/categories/delivery

http://host/api/categories/delivery/food

http://host/api/categories/delivery/medicine

How can I pull everything after the word "categories" as a single string (and split it myself) or as a list of strings? Essentially getting List("delivery","medicine") out of the third example would be great.

benstpierre
  • 32,833
  • 51
  • 177
  • 288

1 Answers1

2

Super easy answer just use

pathPrefix("listJobCategories" / Segments) { query =>

and query will be List[String]

benstpierre
  • 32,833
  • 51
  • 177
  • 288