Re: [akka-user] [Akka Http 1.0-M4] startHandlingWith / starting server with routes

2015-03-22 Thread Magnus Andersson
Oops copy paste error. Here is the gist for the shim, in case it is useful 
for anyone else:

https://gist.github.com/magnusart/5dfb824eb66e847d1f84

Den söndag 22 mars 2015 kl. 13:40:18 UTC+1 skrev Magnus Andersson:
>
> Hi
>
> This issue really bit me, I was setting up an new akka-http project in 
> Java for a colleague and we could not get it to work. I ended up created a 
> small 
> shim for Scala 
> 
>  so 
> that I could work with Routing in M4 in Scala at least, but the issue of 
> this bug remains in Akka-http for Java. Is there a new milestone coming up 
> or can you release a fix on M4? 
>
> This bug is super easy to fix but renders Akka-http M4 unusable for Java 
> and very hackish for Scala.
>
> /Magnus
>
> Den fredag 27 februari 2015 kl. 21:33:40 UTC+1 skrev rkuhn:
>>
>> Hi Peter,
>>
>> the documentation is obviously still lacking, and the Activator template 
>> you are citing has not yet been ported to 1.0-M4. But worse than that, 
>> bindAndStartHandlingWith has a really stupid bug :-( As a work-around, 
>> please use the following instead:
>>
>>   val server = Http().bind("localhost", 8080)
>>
>>   
>>   val future = server.to(Sink.foreach { conn =>
>> println(s"connection from ${conn.remoteAddress}")
>> conn.flow.join(route).run()
>>   }).run()
>>
>>   
>>
>> and then for example:
>>
>>
>>   future.flatMap(s => {
>> println(s"bound to ${s.localAddress}")
>> StdIn.readLine()
>> s.unbind()
>>   }).map(_ => system.shutdown())
>>   .recover{
>> case e: Exception =>
>>   e.printStackTrace()
>>   system.shutdown()
>>   }
>>
>> (The .run() in the connection handler is missing—we are also obviously 
>> lacking a test for the convenience method.)
>>
>> Regards,
>>
>> Roland
>>
>> 27 feb 2015 kl. 18:56 skrev Peter Neyens :
>>
>> Hello,
>>
>> I have been playing around with Akka Http the last few days, starting 
>> with the excellent Typesafe Activator akka-http-microservice 
>>  template.
>>
>> When i tried out my application with 
>> akka-stream-and-http-experimental-1.0-M4, the easy way to start a http 
>> server with routes, stopped working.
>>   Http().bind(
>> interface = config.getString("http.interface"),
>> port = config.getInt("http.port")
>>   ).startHandlingWith(routes)
>>
>> I tried to look in the source code of Http 
>> ,
>>  
>> Route 
>> ,
>>  
>> ... milestone 4, but couldn't figure out how to get it working.
>>
>> I tried
>>   Http().bindAndstartHandlingWith(
>> handler = Route.handlerFlow(routes),
>> interface = config.getString("http.interface"),
>> port = config.getInt("http.port")
>>   )
>> (also there seems to be a camelCase typo in this method)
>> and
>>   Http().startHandlingWithAsyncHandler(
>> handler = Route.asyncHandler(routes),
>> interface = config.getString("http.interface"),
>> port = config.getInt("http.port")
>>   )
>>
>> and with both the server starts up and it logs the requests, but I don't 
>> get any results.
>>
>> I hope this is not a stupid question, but there could be others who will 
>> have the same question.
>>
>> Thanks
>> Peter
>>
>> -- 
>> >> 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 http://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>>
>> *Dr. Roland Kuhn*
>> *Akka Tech Lead*
>> Typesafe  – Reactive apps on the JVM.
>> twitter: @rolandkuhn
>> 
>>  
>>

-- 
>>  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 http://groups.google

Re: [akka-user] [Akka Http 1.0-M4] startHandlingWith / starting server with routes

2015-03-22 Thread Magnus Andersson
Hi

This issue really bit me, I was setting up an new akka-http project in Java 
for a colleague and we could not get it to work. I ended up created a small 
shim for Scala 

 so 
that I could work with Routing in M4 in Scala at least, but the issue of 
this bug remains in Akka-http for Java. Is there a new milestone coming up 
or can you release a fix on M4? 

This bug is super easy to fix but renders Akka-http M4 unusable for Java 
and very hackish for Scala.

/Magnus

Den fredag 27 februari 2015 kl. 21:33:40 UTC+1 skrev rkuhn:
>
> Hi Peter,
>
> the documentation is obviously still lacking, and the Activator template 
> you are citing has not yet been ported to 1.0-M4. But worse than that, 
> bindAndStartHandlingWith has a really stupid bug :-( As a work-around, 
> please use the following instead:
>
>   val server = Http().bind("localhost", 8080)
>
>   
>   val future = server.to(Sink.foreach { conn =>
> println(s"connection from ${conn.remoteAddress}")
> conn.flow.join(route).run()
>   }).run()
>
>   
>
> and then for example:
>
>
>   future.flatMap(s => {
> println(s"bound to ${s.localAddress}")
> StdIn.readLine()
> s.unbind()
>   }).map(_ => system.shutdown())
>   .recover{
> case e: Exception =>
>   e.printStackTrace()
>   system.shutdown()
>   }
>
> (The .run() in the connection handler is missing—we are also obviously 
> lacking a test for the convenience method.)
>
> Regards,
>
> Roland
>
> 27 feb 2015 kl. 18:56 skrev Peter Neyens  >:
>
> Hello,
>
> I have been playing around with Akka Http the last few days, starting with 
> the excellent Typesafe Activator akka-http-microservice 
>  template.
>
> When i tried out my application with 
> akka-stream-and-http-experimental-1.0-M4, the easy way to start a http 
> server with routes, stopped working.
>   Http().bind(
> interface = config.getString("http.interface"),
> port = config.getInt("http.port")
>   ).startHandlingWith(routes)
>
> I tried to look in the source code of Http 
> ,
>  
> Route 
> ,
>  
> ... milestone 4, but couldn't figure out how to get it working.
>
> I tried
>   Http().bindAndstartHandlingWith(
> handler = Route.handlerFlow(routes),
> interface = config.getString("http.interface"),
> port = config.getInt("http.port")
>   )
> (also there seems to be a camelCase typo in this method)
> and
>   Http().startHandlingWithAsyncHandler(
> handler = Route.asyncHandler(routes),
> interface = config.getString("http.interface"),
> port = config.getInt("http.port")
>   )
>
> and with both the server starts up and it logs the requests, but I don't 
> get any results.
>
> I hope this is not a stupid question, but there could be others who will 
> have the same question.
>
> Thanks
> Peter
>
> -- 
> >> 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 http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> *Dr. Roland Kuhn*
> *Akka Tech Lead*
> Typesafe  – Reactive apps on the JVM.
> twitter: @rolandkuhn
> 
>  
>

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


Re: [akka-user] [Akka Http 1.0-M4] startHandlingWith / starting server with routes

2015-02-27 Thread Peter Neyens
That works, thank you very much Roland.

Not as nice as the convenience method indeed :-)

Op vrijdag 27 februari 2015 21:33:40 UTC+1 schreef rkuhn:
>
> Hi Peter,
>
> the documentation is obviously still lacking, and the Activator template 
> you are citing has not yet been ported to 1.0-M4. But worse than that, 
> bindAndStartHandlingWith has a really stupid bug :-( As a work-around, 
> please use the following instead:
>
>   val server = Http().bind("localhost", 8080)
>
>   
>   val future = server.to(Sink.foreach { conn =>
> println(s"connection from ${conn.remoteAddress}")
> conn.flow.join(route).run()
>   }).run()
>
>   
>
> and then for example:
>
>
>   future.flatMap(s => {
> println(s"bound to ${s.localAddress}")
> StdIn.readLine()
> s.unbind()
>   }).map(_ => system.shutdown())
>   .recover{
> case e: Exception =>
>   e.printStackTrace()
>   system.shutdown()
>   }
>
> (The .run() in the connection handler is missing—we are also obviously 
> lacking a test for the convenience method.)
>
> Regards,
>
> Roland
>
> 27 feb 2015 kl. 18:56 skrev Peter Neyens  >:
>
> Hello,
>
> I have been playing around with Akka Http the last few days, starting with 
> the excellent Typesafe Activator akka-http-microservice 
>  template.
>
> When i tried out my application with 
> akka-stream-and-http-experimental-1.0-M4, the easy way to start a http 
> server with routes, stopped working.
>   Http().bind(
> interface = config.getString("http.interface"),
> port = config.getInt("http.port")
>   ).startHandlingWith(routes)
>
> I tried to look in the source code of Http 
> ,
>  
> Route 
> ,
>  
> ... milestone 4, but couldn't figure out how to get it working.
>
> I tried
>   Http().bindAndstartHandlingWith(
> handler = Route.handlerFlow(routes),
> interface = config.getString("http.interface"),
> port = config.getInt("http.port")
>   )
> (also there seems to be a camelCase typo in this method)
> and
>   Http().startHandlingWithAsyncHandler(
> handler = Route.asyncHandler(routes),
> interface = config.getString("http.interface"),
> port = config.getInt("http.port")
>   )
>
> and with both the server starts up and it logs the requests, but I don't 
> get any results.
>
> I hope this is not a stupid question, but there could be others who will 
> have the same question.
>
> Thanks
> Peter
>
> -- 
> >> 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 http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> *Dr. Roland Kuhn*
> *Akka Tech Lead*
> Typesafe  – Reactive apps on the JVM.
> twitter: @rolandkuhn
> 
>  
>

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


Re: [akka-user] [Akka Http 1.0-M4] startHandlingWith / starting server with routes

2015-02-27 Thread Endre Varga
2015.02.27. 21:33 ezt írta ("Roland Kuhn" ):
>
> Hi Peter,
>
> the documentation is obviously still lacking, and the Activator template
you are citing has not yet been ported to 1.0-M4. But worse than that,
bindAndStartHandlingWith has a really stupid bug :-( As a work-around,
please use the following instead:
>
>   val server = Http().bind("localhost", 8080)
>
>
>
>   val future = server.to(Sink.foreach { conn =>
> println(s"connection from ${conn.remoteAddress}")
> conn.flow.join(route).run()
>   }).run()
>
>
>
> and then for example:
>
>
>   future.flatMap(s => {
> println(s"bound to ${s.localAddress}")
> StdIn.readLine()
> s.unbind()
>   }).map(_ => system.shutdown())
>   .recover{
> case e: Exception =>
>   e.printStackTrace()
>   system.shutdown()
>   }
>
> (The .run() in the connection handler is missing—we are also obviously
lacking a test for the convenience method.)

Aaww. A stupid one indeed.

>
> Regards,
>
> Roland
>
>> 27 feb 2015 kl. 18:56 skrev Peter Neyens :
>>
>> Hello,
>>
>> I have been playing around with Akka Http the last few days, starting
with the excellent Typesafe Activator akka-http-microservice template.
>>
>> When i tried out my application with
akka-stream-and-http-experimental-1.0-M4, the easy way to start a http
server with routes, stopped working.
>>   Http().bind(
>> interface = config.getString("http.interface"),
>> port = config.getInt("http.port")
>>   ).startHandlingWith(routes)
>>
>> I tried to look in the source code of Http, Route, ... milestone 4, but
couldn't figure out how to get it working.
>>
>> I tried
>>   Http().bindAndstartHandlingWith(
>> handler = Route.handlerFlow(routes),
>> interface = config.getString("http.interface"),
>> port = config.getInt("http.port")
>>   )
>> (also there seems to be a camelCase typo in this method)
>> and
>>   Http().startHandlingWithAsyncHandler(
>> handler = Route.asyncHandler(routes),
>> interface = config.getString("http.interface"),
>> port = config.getInt("http.port")
>>   )
>>
>> and with both the server starts up and it logs the requests, but I don't
get any results.
>>
>> I hope this is not a stupid question, but there could be others who will
have the same question.
>>
>> Thanks
>> Peter
>>
>> --
>> >> 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 http://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> Dr. Roland Kuhn
> Akka Tech Lead
> Typesafe – Reactive apps on the JVM.
> twitter: @rolandkuhn
>
>
> --
> >> 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 http://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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] [Akka Http 1.0-M4] startHandlingWith / starting server with routes

2015-02-27 Thread Roland Kuhn
Hi Peter,

the documentation is obviously still lacking, and the Activator template you 
are citing has not yet been ported to 1.0-M4. But worse than that, 
bindAndStartHandlingWith has a really stupid bug :-( As a work-around, please 
use the following instead:

  val server = Http().bind("localhost", 8080)
  
  val future = server.to(Sink.foreach { conn =>
println(s"connection from ${conn.remoteAddress}")
conn.flow.join(route).run()
  }).run()
  
and then for example:

  future.flatMap(s => {
println(s"bound to ${s.localAddress}")
StdIn.readLine()
s.unbind()
  }).map(_ => system.shutdown())
  .recover{
case e: Exception =>
  e.printStackTrace()
  system.shutdown()
  }

(The .run() in the connection handler is missing—we are also obviously lacking 
a test for the convenience method.)

Regards,

Roland

> 27 feb 2015 kl. 18:56 skrev Peter Neyens :
> 
> Hello,
> 
> I have been playing around with Akka Http the last few days, starting with 
> the excellent Typesafe Activator akka-http-microservice 
>  template.
> 
> When i tried out my application with 
> akka-stream-and-http-experimental-1.0-M4, the easy way to start a http server 
> with routes, stopped working.
>   Http().bind(
> interface = config.getString("http.interface"),
> port = config.getInt("http.port")
>   ).startHandlingWith(routes)
> 
> I tried to look in the source code of Http 
> ,
>  Route 
> ,
>  ... milestone 4, but couldn't figure out how to get it working.
> 
> I tried
>   Http().bindAndstartHandlingWith(
> handler = Route.handlerFlow(routes),
> interface = config.getString("http.interface"),
> port = config.getInt("http.port")
>   )
> (also there seems to be a camelCase typo in this method)
> and
>   Http().startHandlingWithAsyncHandler(
> handler = Route.asyncHandler(routes),
> interface = config.getString("http.interface"),
> port = config.getInt("http.port")
>   )
> 
> and with both the server starts up and it logs the requests, but I don't get 
> any results.
> 
> I hope this is not a stupid question, but there could be others who will have 
> the same question.
> 
> Thanks
> Peter
> 
> -- 
> >> 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 http://groups.google.com/group/akka-user 
> .
> For more options, visit https://groups.google.com/d/optout 
> .



Dr. Roland Kuhn
Akka Tech Lead
Typesafe  – Reactive apps on the JVM.
twitter: @rolandkuhn
 

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


[akka-user] [Akka Http 1.0-M4] startHandlingWith / starting server with routes

2015-02-27 Thread Peter Neyens
Hello,

I have been playing around with Akka Http the last few days, starting with 
the excellent Typesafe Activator akka-http-microservice 
 template.

When i tried out my application with 
akka-stream-and-http-experimental-1.0-M4, the easy way to start a http 
server with routes, stopped working.
  Http().bind(
interface = config.getString("http.interface"),
port = config.getInt("http.port")
  ).startHandlingWith(routes)

I tried to look in the source code of Http 
,
 
Route 
,
 
... milestone 4, but couldn't figure out how to get it working.

I tried
  Http().bindAndstartHandlingWith(
handler = Route.handlerFlow(routes),
interface = config.getString("http.interface"),
port = config.getInt("http.port")
  )
(also there seems to be a camelCase typo in this method)
and
  Http().startHandlingWithAsyncHandler(
handler = Route.asyncHandler(routes),
interface = config.getString("http.interface"),
port = config.getInt("http.port")
  )

and with both the server starts up and it logs the requests, but I don't 
get any results.

I hope this is not a stupid question, but there could be others who will 
have the same question.

Thanks
Peter

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