- Move JteStaticServing to dev.relism.flash package - Fix imports in HttpStatus and test files - Add fluent config methods to JteExtension (templateRoot, serveStatics, staticPrefix, etc.) - Implement routes() for static asset serving with HEAD support - Include Main.java entry point
flash-ext-view-jte
Opinionated jte SSR extension for Flash.
This module keeps jte semantics front and center:
JteExtensionJteHandler@TemplateViewModelfromflash-ext-view-coreglobal.*reserved namespace
The extension mirrors gg.jte.ContentType into Flash HTTP content type:
gg.jte.ContentType.Html->text/htmlgg.jte.ContentType.Plain->text/plain
Static serving (opinionated)
Static serving is enabled by default and serves classpath assets from /static/**
(src/main/resources/static/**) on an HTTP wildcard route.
Defaults:
serveStatics = truestaticPrefix = "/static"- ETag via CRC32 + length
304 Not ModifiedonIf-None-Match- pre-compressed
.gzsupport when client sendsAccept-Encoding: gzip - MIME auto-resolution for common web/media/font/wasm types
- cache policy:
- versioned assets (
file.<hash>.extor query?v=.../?hash=...) ->public, max-age=31536000, immutable - non-versioned ->
no-cache
- versioned assets (
- byte-range support for large files (threshold configurable, default 64 KiB)
If classpath /static is missing, extension logs a warning and disables static routes.
Configuration examples
// option 1: customizer constructor
app.install(new JteExtension(cfg -> cfg
.templateRoot("/templates")
.serveStatics(true)
.staticPrefix("/assets")));
// option 2: fluent style
app.install(new JteExtension()
.templateRoot("/templates")
.withStaticServing()
.staticPrefix("/assets"));
Disable static serving:
app.install(new JteExtension().serveStatics(false));
Enable static CORS (default disabled):
app.install(new JteExtension().staticCors(cfg -> cfg
.enableStaticCors(true)
.staticCorsAllowOrigin("*")
.staticCorsAllowMethods("GET,HEAD,OPTIONS")
.staticCorsAllowHeaders("*")
.staticCorsMaxAge(3600)));
Quick Start
import jte.view.ext.dev.relism.flash.JteExtension;
FlashApp.create(8080)
.
install(new JteExtension(cfg ->cfg
.
templateRoot("/templates")
.
contentType(gg.jte.ContentType.Html)))
.
scan("com.example.web")
.
startAndBlock();
import core.view.ext.dev.relism.flash.ViewModel;
import jte.view.ext.dev.relism.flash.JteHandler;
import jte.view.ext.dev.relism.flash.Template;
import models.dev.relism.flash.Request;
import routing.dev.relism.flash.GET;
@GET("/")
@Template("pages/home.jte")
public final class HomePage extends JteHandler {
@Override
public ViewModel render(Request req) {
return ViewModel.empty()
.with("page", new HomePageModel("Flash + jte", "elorc"))
.with("build", "dev");
}
public record HomePageModel(String title, String author) {
}
}
Docs
docs/architecture.mddocs/handlers.mddocs/model-and-globals.mddocs/performance.md