{"action":"created","issue":{"url":"https://api.github.com/repos/vert-x3/vertx-web/issues/336","repository_url":"https://api.github.com/repos/vert-x3/vertx-web","labels_url":"https://api.github.com/repos/vert-x3/vertx-web/issues/336/labels{/name}","comments_url":"https://api.github.com/repos/vert-x3/vertx-web/issues/336/comments","events_url":"https://api.github.com/repos/vert-x3/vertx-web/issues/336/events","html_url":"https://github.com/vert-x3/vertx-web/issues/336","id":141225206,"number":336,"title":"provide a JAX-RS like java interface facade over vertx-web","user":{"login":"jstrachan","id":30140,"avatar_url":"https://avatars.githubusercontent.com/u/30140?v=3","gravatar_id":"","url":"https://api.github.com/users/jstrachan","html_url":"https://github.com/jstrachan","followers_url":"https://api.github.com/users/jstrachan/followers","following_url":"https://api.github.com/users/jstrachan/following{/other_user}","gists_url":"https://api.github.com/users/jstrachan/gists{/gist_id}","starred_url":"https://api.github.com/users/jstrachan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jstrachan/subscriptions","organizations_url":"https://api.github.com/users/jstrachan/orgs","repos_url":"https://api.github.com/users/jstrachan/repos","events_url":"https://api.github.com/users/jstrachan/events{/privacy}","received_events_url":"https://api.github.com/users/jstrachan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2016-03-16T10:06:37Z","updated_at":"2016-03-17T09:54:18Z","closed_at":null,"body":"So I grok how folks often prefer the Express style declarative approach, but it can be handy for folks to write Java interfaces with URI template annotations; then folks have both a client and server contract thats typesafe.\r\n\r\nHowever to work in a non-blocking way, the rule needs to be that all methods return Observable<T> so that they are non blocking calls; or maybe they are void for fire and forget method calls.\r\n\r\nThere's a client side example here with Retrofit: http://joluet.github.io/blog/2014/07/07/rxjava-retrofit/\r\n\r\nSo you could have an interface like this:\r\n```\r\n@GET(\"/session.json\")\r\nObservable<LoginResponse> login();\r\n\r\n@GET(\"/user.json\")\r\nObservable<UserState> getUserState();\r\n```\r\n\r\nyou can then use all the lovely RxJava composition methods to join/flatMap etc to compose multiple requests across different microservice invocations together with timeouts etc e.g. to compose the latest from 2 calls:\r\n\r\n```\r\nObservable.combineLatest(api.fetchUserProfile(), api.getUserState(),\r\n(user, userStatus) -> new Pair<>(user, userStatus));\r\n```\r\nNice and simple!\r\n\r\nAdmittedly the java interface approach is more focussed on clients; but its also a nice easy way to implement a service too.\r\n\r\nFrom the server side, we could just do introspection over a class and find all the @GET / @POST / @PUT / @DELETE annotations and add a new route...\r\n```\r\nrouter.route(uriPath).consumes(...).produces(...).handle(...);\r\n```\r\nwhere some marshalling is used to convert things to/from DTOs (e.g. jackson for JSON/YAML or Protobuf et al).\r\n\r\nWe could even get clever and do APT style compiler code generation to avoid any runtime introspection.\r\n\r\nThe client side could work the same too; generating an implementation of the interface that just delegates to the Vertx RxJava + HTTP Client calls?\r\n"},"comment":{"url":"https://api.github.com/repos/vert-x3/vertx-web/issues/comments/197795268","html_url":"https://github.com/vert-x3/vertx-web/issues/336#issuecomment-197795268","issue_url":"https://api.github.com/repos/vert-x3/vertx-web/issues/336","id":197795268,"user":{"login":"jstrachan","id":30140,"avatar_url":"https://avatars.githubusercontent.com/u/30140?v=3","gravatar_id":"","url":"https://api.github.com/users/jstrachan","html_url":"https://github.com/jstrachan","followers_url":"https://api.github.com/users/jstrachan/followers","following_url":"https://api.github.com/users/jstrachan/following{/other_user}","gists_url":"https://api.github.com/users/jstrachan/gists{/gist_id}","starred_url":"https://api.github.com/users/jstrachan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jstrachan/subscriptions","organizations_url":"https://api.github.com/users/jstrachan/orgs","repos_url":"https://api.github.com/users/jstrachan/repos","events_url":"https://api.github.com/users/jstrachan/events{/privacy}","received_events_url":"https://api.github.com/users/jstrachan/received_events","type":"User","site_admin":false},"created_at":"2016-03-17T09:54:18Z","updated_at":"2016-03-17T09:54:18Z","body":"sounds great!"}}