scala - Getting the last segment of path in case of using OR condition -
i new spray framework, have 2 routes have similar functionality , last segment changes. have combined using ‘|’ operator. how can know last segment selected.
path("users" / segment / "viewers_count") { userid => } path("users" / segment / "views_count") { userid => }
i have combined using
path("users" / segment / ("viewers_count" | "views_count")) { userid => //here want know if viewers_count or views_count // based on want pass "viewers" or "views" module }
how can achieve this.
it's quite simple. can extract map.
path("users" / segment / map("viewers_count" -> "viewers", "views_count" -> "views")) { (userid, selected) => // here selected variable contain viewers or views based on path. }
Comments
Post a Comment