Hi Daniel,
Before I dive into your question I'd like to highlight that the Java directives 
are undergoing an intense
rewrite just now (they're still experimental, so that's why we must do it now), 
and will be way more elastic soon: 
https://github.com/akka/akka/pull/19632/files?diff=unified

So it's not a very good time to invest heavily into the existing JavaDSL.

I'll give your exact need a closer look a bit later to see how we cover it in 
the new DSL.

-- 
Cheers,
Konrad 'ktoso’ Malawski
Akka @ Typesafe

On 15 February 2016 at 16:45:14, Daniel Stoner (daniel.sto...@ocado.com) wrote:

The current documentation for AkkaHttp directives:
http://doc.akka.io/docs/akka-stream-and-http-experimental/2.0.3/java/http/routing-dsl/directives/index.html#directives-java

Says you can filter requests and modify requests/responses.

I'd love to be able to implement such a thing - but I've seen no examples of 
custom directives in Java.

Does anyone have an example they could post that shows modifying 
request/response. My use case is that I need to implement several things (As 
separate directives):
1) The equivalent of server access logs (Saying someone tried to go to 
/GET?queryParam=x and this took 120ms to respond)
2) Authentication via an external OAUTH system where requests may be rejected 
with the equivalent of access denied responses. [Perhaps this is better done as 
a Handler implementation? What are your thoughts?]

I get how I could potentially nest handlers in a way such that I can do:
pathSingleSlash().route(
 get(path("home").route(handleWidth(new AuthenticationHandler(homeHandler)))
 post(path("home").route(handleWidth(new 
AuthenticationHandler(homePostHandler)))
)

But I think Directives sound like the better place to put this logic at the top 
of the route tree rather than repeat it constantly in all the bottom leaves.

Thanks kindly,
Daniel Stoner
--
Daniel Stoner | Senior Software Engineer UtopiaIT | Ocado Technology
daniel.sto...@ocado.com | Ext 7969 | www.ocadotechnology.com


Notice:  This email is confidential and may contain copyright material of 
members of the Ocado Group. Opinions and views expressed in this message may 
not necessarily reflect the opinions and views of the members of the Ocado 
Group. 
 
If you are not the intended recipient, please notify us immediately and delete 
all copies of this message. Please note that it is your responsibility to scan 
this message for viruses. 
 
Fetch and Sizzle are trading names of Speciality Stores Limited, a member of 
the Ocado Group.
 
References to the “Ocado Group” are to Ocado Group plc (registered in England 
and Wales with number 7098618) and its subsidiary undertakings (as that 
expression is defined in the Companies Act 2006) from time to time.  The 
registered office of Ocado Group plc is Titan Court, 3 Bishops Square, Hatfield 
Business Park, Hatfield, Herts. AL10 9NE.
--
>>>>>>>>>> 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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
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