Micronaut: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:
@Controller("/hello")
@Controller("/hello")
public class HelloController {
public class HelloController {
 
    @Get("/")
  @Get("/")
    public String index() {
  public String index() {
        return "Hello World";
    return "Hello World";
    }
  }
}
}
</source>
</source>
Line 21: Line 20:
@Client("/hello")
@Client("/hello")
public interface HelloClient {
public interface HelloClient {
  @Get("/")
    @Get("/")
  Single<String> hello();
    Single<String> hello();
}
}
</source>
</source>

Revision as of 10:54, 26 August 2021

Server

import io.micronaut.http.annotation.*;

@Controller("/hello")
public class HelloController {
    @Get("/")
    public String index() {
        return "Hello World";
    }
}

Client

import io.micronaut.http.annotation.Get;
import io.micronaut.http.client.annotation.Client;
import io.reactivex.Single;

@Client("/hello")
public interface HelloClient {
    @Get("/")
    Single<String> hello();
}

References