Hi Elliot, look at the directives and custom directives parts of the docs, that should help you get going: http://doc.akka.io/docs/akka-http/current/scala/http/routing-dsl/directives/index.html
-- Johan Akka Team On Thu, Nov 24, 2016 at 1:22 PM, Elliot Laurendeau <[email protected]> wrote: > Hi, > > I'm currently working on a Scala akka http projet and i implemented Async > auth. > > Ex of my structure (these isn't my real project, its just easier to > picture it): > > HttpRouter : Choose the arborescence of the URL > > AuthController: has a user register and auth callback from an external > website. URL : auth/action > CarController: has a car search function and bike register function > BikeController: has a bike search and bike register function > > The HTTP Router looks like the following: > > val routes = { > authRoutes ~ pathPrefix("secured") { > authenticateBasicAsync(realm = "secure site", userAuthenticator) { > user => > carRoutes ~ bikeRoutes > } > } > } > > > I'm adding the login security in the HttpRouter rather than in each seperate > module. > > > My question: > > Within my carRoutes and my bikeRoutes, i have a register function to add the > object to my list of sold items. > > When a request is calling that /add method, i want to pass a reference of my > authenticated user to mark him as the seller. > > > Is it possible to pass my user object (see below) to my child/sub routes? > > > authenticateBasicAsync(realm = "secure site", userAuthenticator) { > *user *=> > carRoutes(i want my user to be passed along here) ~ bikeRoutes(i > want my user to be passed along here) > } > > > For testing purposes, I duplicated the authenticateBasicAsync line in my > child routes and it works, but i'm calling my validate user twice. It works > but i don't like this method. > > > Anyone know a better solution? > > > Thanks > > -- > >>>>>>>>>> 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.
