title: REST client interface can not be injected in Quarkus kotlin app
body: <p>I tried to add a <code>quarkus-rest-client</code> sample for my <a href="https://github.com/hantsy/quarkus-sandbox/tree/master/post-service" rel="nofollow noreferrer">post-service</a> which is a simple REST API built with Quarkus. </p>
  
  <p>The java version is working well.</p>
  
  <p>When I added another Kotlin to test the kotlin and Gradle support in Quarkus, it failed, the REST Client interface can not be injected as CDI bean. </p>
  
  <p>The <code>PostControlloer</code> is Jaxrs resource to expose an aggregated APIs that combined the original two APIs. </p>
  
  <pre><code>@Path("/api")
  @RequestScoped
  class PostController(@Inject @RestClient val client: PostResourceClient) {
  
  //    @Inject
  //    @RestClient
  //    lateinit var client: PostServiceClient
  
      @GET
      @Produces(MediaType.APPLICATION_JSON)
      fun getPosts(@QueryParam("q")
                   q: String,
                   @QueryParam("offset")
                   @DefaultValue("0")
                   offset: Int,
                   @QueryParam("limit")
                   @DefaultValue("10")
                   limit: Int): Response {
          val posts = this.client.getAllPosts(q, offset, limit).entity as List&lt;Post&gt;
          val count = this.client.countAllPosts(q).entity as Long
          return ok(PostPage(posts, count)).build()
      }
  
  }
  
  </code></pre>
  
  <p>The above two approaches to inject a Bean are failed.</p>
  
  <p>The REST Client interface:</p>
  
  <pre><code>@Path("/posts")
  @RegisterRestClient
  interface PostResourceClient {
  
      @GET
      @Produces(MediaType.APPLICATION_JSON)
      fun getAllPosts(
              @QueryParam("q")
              q: String,
              @QueryParam("offset")
              @DefaultValue("0")
              offset: Int,
              @QueryParam("limit")
              @DefaultValue("10")
              limit: Int
      ): Response
  
      @GET
      @Path("count")
      @Produces(MediaType.APPLICATION_JSON)
      fun countAllPosts(
              @QueryParam("q")
              q: String
      ): Response
  
  }
  </code></pre>
  
  <p>The application config for this Rest Client interface. </p>
  
  <pre><code>com.example.PostResourceClient/mp-rest/url=http://localhost:8080
  com.example.PostResourceClient/mp-rest/scope=javax.inject.Singleton
  </code></pre>
  
  <p>The complete codes is <a href="https://github.com/hantsy/quarkus-sandbox/blob/master/post-service-client-kotlin" rel="nofollow noreferrer">here</a>.</p>