Java Library for Ableron Server Side UI Composition
Gradle:
implementation 'io.github.ableron:ableron:1.9.0'
Maven:
<dependency>
<groupId>io.github.ableron</groupId>
<artifactId>ableron</artifactId>
<version>1.9.0</version>
</dependency>
- Init ableron
var ableron = new Ableron(AbleronConfig.builder() .cacheMaxSizeInBytes(1024 * 1024 * 50) .build());
- Use includes in response body
<html> <head> <ableron-include src="https://head-fragment" /> </head> <body> <ableron-include src="https://body-fragment" fallback-src="https://fallback-body-fragment"><!-- Static fallback fragment goes here --></ableron-include> </body> </html>
- Apply transclusion to response if applicable (HTTP status 2xx, 4xx or 5xx; Response content type is non-binary, ...)
// perform transclusion based on unprocessed response body and request headers from e.g. HttpServletRequest TransclusionResult transclusionResult = ableron.resolveIncludes(getOriginalResponseBody(), getRequestHeaders()); // set body to the processed one setResponseBody(transclusionResult.getContent()); // override response status code when primary include was present transclusionResult.getStatusCodeOverride().ifPresent(statusCode -> setResponseStatusCode(statusCode)); // add response headers when primary include was present addResponseHeaders(transclusionResult.getResponseHeadersToPass()); // set cache-control header getResponse().setHeader(CACHE_CONTROL, transclusionResult.calculateCacheControlHeaderValue(getResponseHeaders()));
Default: true
Whether UI composition is enabled.
Default: 3 seconds
Timeout for requesting fragments.
Default:
List.of(
"Accept-Language",
"Correlation-ID",
"Forwarded",
"Referer",
"User-Agent",
"X-Correlation-ID",
"X-Forwarded-For",
"X-Forwarded-Proto",
"X-Forwarded-Host",
"X-Real-IP",
"X-Request-ID"
);
Request headers that are passed to fragment requests, if present.
Default: []
Extends fragmentRequestHeadersToPass
. Use this property to pass all headers defined in fragmentRequestHeadersToPass
plus the additional headers defined here. This prevents the need to duplicate fragmentRequestHeadersToPass
if the only
use case is to add additional headers instead of modifying the default ones.
List.of(
"Content-Language",
"Location",
"Refresh"
);
Response headers of primary fragments to pass to the page response, if present.
Default: 10 MB
Maximum size in bytes the fragment cache may have.
Default: empty list
Fragment request headers which influence the requested fragment aside from its URL. Used to create fragment cache keys.
Must be a subset of fragmentRequestHeadersToPass
. Common example are headers used for steering A/B-tests.
Default: false
Whether to append UI composition stats as HTML comment to the content.
Default: false
Whether to expose fragment URLs in the stats appended to the content.