Service Descriptors
named("hello").withCalls(
namedCall("hello", sayHello)
)
用/hello 调用了sayHello方法
def getOrder(orderId: Long): ServiceCall[NotUsed, Order]
override def descriptor = {
import Service._
named("orders").withCalls(
pathCall("/order/:id", getOrder _)
)
}
用uri路径调用方法
def addItem(orderId: Long): ServiceCall[Item, NotUsed]
def getItem(orderId: Long, itemId: String): ServiceCall[NotUsed, Item]
def deleteItem(orderId: Long, itemId: String): ServiceCall[NotUsed, NotUsed]
def descriptor = {
import Service._
import com.lightbend.lagom.scaladsl.api.transport.Method
named("orders").withCalls(
restCall(Method.POST, "/order/:orderId/item", addItem _),
restCall(Method.GET, "/order/:orderId/item/:itemId", getItem _),
restCall(Method.DELETE, "/order/:orderId/item/:itemId", deleteItem _)
)
}
也可以用REST方法调用