I am new to scala and I am trying to implement CORS mechanism on my Scala Application. We have 2 methods in my app one ads the CORS headers to Preflight OPTIONS request and other one that ads headers to all other responses. below are the methods
Now, I am trying to get the current HTTP request inside my addAccessControlHeaders method via extractRequest Directive but whatever the code I have written inside extractRequest is not getting executed. I could use exractRequest directive in the first method ( preflight handler) but not on the second method. Can we use extractRequest inside a method that is returning a Directive? if not how can we get the current HttpRequest in scala.