Akka-http : Load html page with dynamic values (location search property)

410 views
Skip to first unread message

Mayank Bairagi

unread,
May 9, 2016, 6:14:57 AM5/9/16
to Akka User List
Hi there ,
I have a use case. Here is an akka-http route.

get {
      pathPrefix
("someRoute") {
        pathEndOrSingleSlash
{
          getFromResource
("index.html")
       
}
     
} }

my index.html is as follows
<!DOCTYPE html>
<html>
<head>
 
<script type="text/javascript">
      alert
('QUERY PARMS : '+window.location.search)
 
</script>
</head>
</html>

When I call index.html from browser 
file:///index.html?email=may...@knoldus.com
Here I got alert
"QUERY PARMS : ?email=may...@knoldus.com"


Is there any way in akka-http so that I can supply some dynamic query parameters while loading index.html?

Thanks in advance!!

Akka Team

unread,
May 10, 2016, 5:38:59 AM5/10/16
to Akka User List
Hi Mayank,

You likely need a templating engine and you should pass parsed and validated parameters to it. One option is swirl, which is the template engine of Play (https://github.com/playframework/twirl), or there is scalatags (https://github.com/lihaoyi/scalatags) which uses a DSL to generate HTML compared to raw HTML.

-Endre

--
>>>>>>>>>> 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+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at https://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
Reply all
Reply to author
Forward
0 new messages