Micronaut: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
No edit summary
 
Line 1: Line 1:
==Server==
==Server==
<source lang="java">
<syntaxhighlight lang="java">
import io.micronaut.http.annotation.*;
import io.micronaut.http.annotation.*;


Line 10: Line 10:
     }
     }
}
}
</source>
</syntaxhighlight>


==Client==
==Client==
<source lang="java">
<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 23: Line 23:
     Single<String> hello();
     Single<String> hello();
}
}
</source>
</syntaxhighlight>


==References==
==References==

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