简体   繁体   中英

scala + akka http - how to match entire url with path directive

I have a url

http://localhost:8080/api/search/lookup?limit=3000&m=airid.appname.mapping {appname=*}

path("api"/"search"/"lookup?limit=3000&m=appname.server.mapping") is unavailable

how to match the entire url including parameters and values?

The part of the url after the '?' is referred to as the query string and is technically not part of the path:

a query string is the part of a uniform resource locator (URL) containing data that does not fit conveniently into a hierarchical path structure

Therefore, you cannot access it using the path directive . If you want the entire uri then you need extractUri :

val myRoute = extractUri { uri =>
  //rest of Route logic
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM