All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.micronaut.starter.feature.view.reactControllerJava.rocker.raw Maven / Gradle / Ivy

There is a newer version: 4.7.0
Show newest version
@import io.micronaut.starter.application.Project

@args (
Project project
)

@if (project.getPackageName() != null) {
package @project.getPackageName();
}

import io.micronaut.core.annotation.Introspected;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import io.micronaut.http.HttpResponse;
import io.micronaut.serde.annotation.Serdeable;
import io.micronaut.views.View;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;

@@Controller
public class AppController {
    @@Serdeable.Serializable
    public record CurrentTime(String now) {}

    @@Introspected
    public record InitialProps(String name) {
    }

    @@View("App")
    @@Get
    public HttpResponse index() {
        return HttpResponse.ok(new InitialProps("'your name goes here'"));
    }

    @@Get("/api/time")
    public CurrentTime time() {
        return new CurrentTime(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).format(LocalDateTime.now()));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy