How to read request parameters in akka-http?

I know that akka-http libraries are marshals and not marshals to class type during request processing. But now I need to read the GET request request parameters. I tried the parameter() method and returns the type ParamDefAux , but I need these values ​​as string types

I check the answer to the questions below.

but cannot do what I need.

Please tell me how I can extract the request parameters from the request. OR How to extract the required value from ParamDefAux

Request url

 http://host:port/path?key=authType&value=Basic345 

Get method definition

  val propName = parameter("key") val propValue = parameter("value") complete(persistanceMgr.deleteSetting(propName,propValue)) 

Declarations of my methods

 def deleteSetting(name:String,value:String): Future[String] = Future{ code... } 
+5
source share
1 answer

For a request like http://host:port/path?key=authType&value=Basic345 try

 path("path") { get { parameters('key.as[String], 'value.as[String]) { (key, value) => complete { someFunction(key,value) } } } } 
+11
source

Source: https://habr.com/ru/post/1257428/


All Articles