use of io.micronaut.http.annotation.Produces in project micronaut-starter by micronaut-projects.
the class ApplicationController method home.
/**
* Provides a description of the API.
* @param request The request
* @return A description of the API.
*/
@Get("/")
@Produces(MediaType.TEXT_PLAIN)
@ApiResponse(responseCode = "200", description = "A textual description of the API", content = @Content(mediaType = MediaType.TEXT_PLAIN))
HttpResponse<Writable> home(HttpRequest<?> request, @Parameter(hidden = true) RequestInfo info) {
Collection<MediaType> accept = request.accept();
URI redirectURI = configuration.getRedirectUri().orElse(null);
if (accept.contains(MediaType.TEXT_HTML_TYPE) && redirectURI != null) {
return HttpResponse.permanentRedirect(redirectURI);
} else {
return HttpResponse.ok(new Writable() {
@Override
public void writeTo(Writer out) {
// no-op
}
@Override
public void writeTo(OutputStream outputStream, @Nullable Charset charset) {
new RockerWritable(new starterApi().serverURL(info.getServerURL()).micronautVersion(VersionInfo.getMicronautVersion())).write(outputStream);
}
});
}
}
Aggregations