server.km 712 B

1234567891011121314151617181920212223242526
  1. type EchoServer impl(echo::#Service) {
  2. verbose: Bool
  3. };
  4. method EchoServer.echo: rpc::Method[echo::#Request, echo::#Response]
  5. &(this) => &(req) =>
  6. if this.verbose:
  7. { return { |echo::#Response| {
  8. content: { "Reply: ?" req.content }
  9. } } },
  10. else:
  11. { return { |echo::#Response| {
  12. content: req.content
  13. } } };
  14. entry
  15. { rpc::serve {
  16. service: echo::#Service,
  17. backend: echo::DefaultServerBackend,
  18. options: {},
  19. constructor: &(arg,_) =>
  20. { return { |echo::#Service| { |EchoServer| {
  21. verbose: arg.verbose
  22. } } } }
  23. } }
  24. . { crash-on-error };