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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -