Akka实战:构建REST风格的微服务
使用Akka-Http构建REST风格的微服务,服务API应尽量遵循REST语义,数据使用JSON格式交互。在有错误发生时应返回: {"errcode":409,"errmsg":"aa is invalid,the ID is expected to be bb"} 类似的JSON错误消息。 代码: https://github.com/yangbajing/akka-action http://git.oschina.net/yangbajing/akka-action 代码 首先来看看代码文件结构: ├── ApiRoute.scala ├── App.scala ├── ContextProps.scala ├── book │ ├── Book.scala │ ├── BookContextProps.scala │ ├── BookRoute.scala │ └── BookService.scala └── news ├── News.scala ├── NewsContextProps.scala ├── NewsRoute.scala └── NewsService.scala 通过名字可以看出, App.scala 是启动程序,以 Route 结尾的是API路由定义文件, Service 结尾的就是服务实现代码了。 ContextProps