Hi Leon,

It is definitely possible to flexibly organize your routing logic. In fact
a route is nothing more than this:

  type Route = RequestContext ⇒ Future[RouteResult]

Plus a DSL that gives various tools for composing routes in flexible ways.
It does not change the fact though that a route is just an asynchronous
function and you are free to implement it in any way it fits your
application.

See the high level Server side API documentation especially this page for
more details:

http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0/scala/http/routing-dsl/routes.html
-Endre

On Wed, Aug 26, 2015 at 12:04 PM, Leon Ma <[email protected]> wrote:

> Hi,
>
> I just checked the TestServer in akka-http-tests project.
>
> I'm wondering  whether I can do dispatching logic with handleXXXX method
> like below: (Or, do dispatching within a Route which can be implicitly
> transformed to a flow)
>
>     val binding = Http().bindAndHandleAsync({
>
>       case req@HttpRequest(_, Uri.Path("/admin"), _, _, _)     => call
> some other Route
>
>       case req@HttpRequest(_, Uri.Path("/biz"), _, _, _)     =>  ask an
> actor to get a Future[Response]
>
>       case _: HttpRequest ⇒ defaultResponse() // to return a default
> Future[HttpResponse]
>
>     }, interface = "localhost", port = 9001)
>
>
> I'm asking this is because for a complex application, user might push down
> logic into lower level artifacts instead of binding it directly at the very
> top.
>
> And I'm not sure if it's a good practice to use bindAndHandleAsync of
> doing this dispatching, or should I use a Flow with bindAndHandle?
>
>
>
>
> Thanks in advance!
>
>
> Leon
>
> --
> >>>>>>>>>> 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 http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Akka Team
Typesafe - Reactive apps on the JVM
Blog: letitcrash.com
Twitter: @akkateam

-- 
>>>>>>>>>>      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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to