--
You received this message because you are subscribed to the Google Groups "spray.io User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spray-user+...@googlegroups.com.
Visit this group at https://groups.google.com/group/spray-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/spray-user/9815e6a0-8fd2-489b-a964-b185b3108871%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On 24 May 2016, at 16:12, Conor Reedy <ofrequisi...@gmail.com> wrote:Sorry if I'm doing this wrong...This is the actual code I'm using the handle this route. What I want to happen is much like the parameters directive where the params are cast to variables in the directive so the following code can assume they are present. In this way the "validation" of the params in assumed and won't need to be handled in the route directly. In this the correct params would be extracted and the following code would be able to handle the params directly (instead of being wrapped in an Option or Try).
I guess what I'm trying to get at here is how to properly reject a route where the parameters are not valid. Is there a built in way of doing this? I can't seem to figure out how to properly reject something without throwing an exception and have the exception handler deal with it. To me it seems like the rejections get run after the exception handler (is this correct)?
// there are imports but I haven't included themclass RangeTransactionHandler extends ConfigurableHttpHandler {import context.dispatcheroverride val route =parameterMultiMap { params => // in this I just get the extracted map without any validationval accountIds = gets("accountId", params)val startDate = get ("startDate", params)val endDate = get ("endDate", params )val request = GetTransactionsRequest(accountIds,GzoConfig.environment,toLocalDate(startDate),toLocalDate(endDate)).getItems.getTransactionsonComplete(request) { value =>value match {case Success(value) => complete(JsonResponse(value.map(_.toJson).toVector, Vector()))case Failure(ex) => complete(JsonResponse(Vector(), Vector(ex.getMessage)))}}}}On Tuesday, May 24, 2016 at 9:44:07 AM UTC-4, Conor Reedy wrote:Is there a way to handle rejections for a paramterMultiMap in the same way the parameters directive handles rejections?parameters("one", "two") { (one: String, two: String) =>/* code that can assume all params are correct */}The problem I'm having is handling missing params in the MultiMap. If I write code that assumes the params are correct I will be getting exceptions thrown. I would like a way to reject the request up front so the following code can be simpler.Thanks for your time,Conor
--
You received this message because you are subscribed to the Google Groups "spray.io User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spray-user+...@googlegroups.com.
Visit this group at https://groups.google.com/group/spray-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/spray-user/37ab4ce3-16a4-445a-8122-ddffd1621c84%40googlegroups.com.