首页  

akka http rest api demo     所属分类 akka 浏览量 529
根据官网例子改写  sbt 改成 maven
Akka HTTP Fundamentals  Scala 版本
https://developer.lightbend.com/guides/akka-http-quickstart-scala/

Akka HTTP offers a general toolkit for providing and consuming HTTP-based services. 
The Akka HTTP modules implement a full server- and client-side HTTP stack on top of akka-actor and akka-stream.

用户注册 rest api 

curl -H "Content-type: application/json" -X POST -d '{"name": "MrX", "age": 31, "countryOfResidence": "Canada"}' http://localhost:8080/users

curl -H "Content-type: application/json" -X POST -d '{"name": "Anonymous", "age": 55, "countryOfResidence": "Iceland"}' http://localhost:8080/users

curl -H "Content-type: application/json" -X POST -d '{"name": "Bill", "age": 67, "countryOfResidence": "USA"}' http://localhost:8080/users


curl http://localhost:8080/users

curl http://localhost:8080/users/Bill

curl -X DELETE http://localhost:8080/users/Bill


QuickstartApp.scala – contains the main method which bootstraps the application
UserRoutes.scala – Akka HTTP routes defining exposed endpoints
UserRegistry.scala – the actor which handles the registration requests
JsonFormats.scala – converts the JSON data from requests into Scala types and from Scala types into JSON responses

完整代码
https://gitee.com/dyyx/hellocode/tree/master/demo/scala/akka/akka-http-quickstart-scala-maven

上一篇     下一篇
scala case class

How is Akka used in Play

akka actor demo

c语言 hello world 高逼格版本

IDEA 源码阅读技巧

Scala 实用代码