The RequestContext only contains the part of the path that is not yet
matched, it doesn't really know anything else about how you consumed the
path. "hello"/Segment/"world" would consume up to the end of "world", so I
cannot see how you would achieve the getName method as you describe it. I
think you would have devise your own path-like directive to achieve this,
using mapRequestContext and mapRequest would let you modify the request
path and the consumed path.

--
Johan
Akka Team

On Sun, Mar 19, 2017 at 8:55 PM, AL <[email protected]> wrote:

> Hi,
> Is there an option to extract uri full without the segments values using ?
> simplified example:
>
> val route = get{
>     path("hello"/Segment/"world"){ segment =>
>       ctx.complete{
>         StatusCodes.OK
>       }
>     }
>   }
>
> I am want to collect the Api requests without the segment
>
>  def getName(ctx: RequestContext): String = {
>     ???
>   }val extractor =
>     mapInnerRoute { route => ctx =>
>       try {
>         ctx.complete(getName(ctx))
>       } catch {
>         case NonFatal(e) => ctx.complete(s"Got ${e.getClass.getSimpleName} 
> '${e.getMessage}'")
>       }
>     }
> val checkedRoute = extractor{
>   route}
>
> The function getName should return the uri path WITHOUT the segment value
> e.g:
>
> "hello.segment.world"
>
> "return api uri without segment value" in {
>       Get("/hello/beautiful/world") ~> checkedRoute ~>  check {
>         responseAs[String] shouldEqual "hello.segment.world"
>       }
>     }
>
>
> is that possible with mapInnerRoute ? or I have to explicitly implement
> and call it in each route ?
>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/
> current/additional/faq.html
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to