I want to write a custom directive which adds the query params of the request to its form fields map.
What I have come up till now is something like this
def extractQueryProxyRequestContext: Directive0 = {
extract { ctx =>
val queryParams = ctx.request.uri.query().toMap
val formData = ctx.request.entity.asInstanceOf[FormData]
val updatedFields = formData.fields ++ queryParams
}
}
Obviously, this doesn't work, as this just combines them but not pass the updated fields down the request.
You probably want to use
mapRequestormapRequestContextdirectives rather thanextractif your goal is to modify the initial request.