Micronaut: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
==Server== | ==Server== | ||
< | <syntaxhighlight lang="java"> | ||
import io.micronaut.http.annotation.*; | import io.micronaut.http.annotation.*; | ||
@Controller("/hello") | @Controller("/hello") | ||
public class HelloController { | public class HelloController { | ||
@Get("/") | |||
public String index() { | |||
return "Hello World"; | |||
} | |||
} | } | ||
</ | </syntaxhighlight> | ||
==Client== | ==Client== | ||
< | <syntaxhighlight lang="java"> | ||
import io.micronaut.http.annotation.Get; | import io.micronaut.http.annotation.Get; | ||
import io.micronaut.http.client.annotation.Client; | import io.micronaut.http.client.annotation.Client; | ||
Line 21: | Line 20: | ||
@Client("/hello") | @Client("/hello") | ||
public interface HelloClient { | public interface HelloClient { | ||
@Get("/") | |||
Single<String> hello(); | |||
} | } | ||
</ | </syntaxhighlight> | ||
==References== | ==References== | ||
Line 33: | Line 32: | ||
| valign="top" | | | valign="top" | | ||
| valign="top" | | |||
|- | |||
| colspan="3" | | |||
---- | |||
|- | |||
| valign="top" | | |||
* [[Dropwizard]] | |||
| valign="top" | | |||
| valign="top" | | |||
|} | |} |
Latest revision as of 10:04, 26 October 2024
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
| ||