A tinystruct-based module to enable Undertow server support. It starts an embedded Undertow server with tinystruct routing capabilities.
- Embedded Undertow 2.3.12.Final (High-performance, non-blocking I/O server)
- Tinystruct-powered request routing via
/?q=... - Static file serving from project root
- Server-Sent Events (SSE) support (including MCP SSE)
- Simple CLI bootstrap with configurable server port and proxy settings
- Java 17+
- Maven 3.8+
mvnw clean packageArtifacts:
target/tinystruct-undertow-server-<version>-jar-with-dependencies.jar- Dependencies copied to
lib/(via maven-dependency-plugin)
You can run via the provided dispatcher scripts (recommended) or manually with java.
The bin/dispatcher (Unix) and bin/dispatcher.cmd (Windows) scripts bootstrap tinystruct actions.
- Unix/macOS:
bin/dispatcher start --import org.tinystruct.system.UndertowServer --server-port 8080- Windows (PowerShell or cmd):
bin\dispatcher.cmd start --import org.tinystruct.system.UndertowServer --server-port 8080Flags you can pass through the CLI (examples):
--server-port 7777--http.proxyHost host --http.proxyPort 8080--https.proxyHost host --https.proxyPort 8443
When the server starts, it attempts to open the default browser at http://localhost:<port>.
After building the jar-with-dependencies:
java -cp target/tinystruct-undertow-server-1.0.0-jar-with-dependencies.jar;lib/* org.tinystruct.app.Application startNote: On Unix-based shells, replace ; with : in the classpath.
- Entry point:
org.tinystruct.system.UndertowServer(startaction) - Embedded Undertow is configured with a default handler for static assets and an HTTP handler (
DefaultHandler)- Initializes tinystruct
ApplicationManager - Routes requests using the
qparameter (e.g.,/?q=say/Hello) or serves a default page configured via settings - Supports SSE when
Accept: text/event-streamis present
- Initializes tinystruct
Core classes:
org.tinystruct.system.UndertowServerorg.tinystruct.system.UndertowServer.DefaultHandlerorg.tinystruct.http.undertow.RequestBuilderorg.tinystruct.http.undertow.ResponseBuilder
Tinystruct Settings are read at startup. You can set these via your runtime environment or tinystruct configuration files:
default.file.encoding(e.g.,UTF-8)language(defaults tozh_CNunless overridden)system.directory(defaults to the current working directory)default.url_rewrite(enabledto use clean URLs; otherwise falls back to/?q=)default.home.page(default action whenqis missing; e.g.,say/Welcome)default.error.page(action to route errors; e.g.,error)default.error.process(boolean; when false, forwards todefault.error.page)ssl.enabled(boolean; toggles protocol in generated host URLs)
Proxy (optional via CLI context):
--http.proxyHost,--http.proxyPort--https.proxyHost,--https.proxyPort
- Static files: served from the current working directory by the default handler.
- Dynamic actions:
/?q=<namespace>/<action>handled by tinystruct. Example:http://localhost:8080/?q=say/Hello
- Language override:
?lang=en_US(applies if supported and different from currentlanguagesetting)
To initiate an SSE stream, send requests with Accept: text/event-stream and a q pointing to an action that supports streaming.
For MCP SSE, q must equal the MCP endpoint (see MCPSpecification.Endpoints.SSE). The server sets up the appropriate response headers and streams events.
- Source:
src/main/java - Tests:
src/test/java
Useful Maven commands:
mvnw -q -DskipTests package
mvnw testApache License 2.0. See LICENSE-2.0.txt.
<dependency>
<groupId>org.tinystruct</groupId>
<artifactId>tinystruct-undertow-server</artifactId>
<version>1.0.0</version>
</dependency>- Website:
https://tinystruct.org - Repository SCM:
https://github.com/tinystruct/tinystruct