Add constructors and Javadoc comments to improve clarity and completeness across server components, including WebSocket and routing classes.
Auto Publish on Version Change / check-and-publish (push) Successful in 14s
Run Tests on Push and Pull Request / run-tests (push) Successful in 18s

This commit is contained in:
CodingPhoenixx
2026-05-29 09:00:31 +02:00
parent 5d6e8622bf
commit a7b65c031d
8 changed files with 79 additions and 1 deletions
@@ -99,6 +99,8 @@ public final class CorsConfig {
}
/**
* Returns the HTTP methods advertised as allowed in preflight responses.
*
* @return the immutable set of allowed HTTP methods
*/
public Set<HttpMethod> allowedMethods() {
@@ -106,6 +108,8 @@ public final class CorsConfig {
}
/**
* Returns the request headers advertised as allowed in preflight responses.
*
* @return the immutable set of allowed request headers
*/
public Set<String> allowedHeaders() {
@@ -113,6 +117,8 @@ public final class CorsConfig {
}
/**
* Returns the response headers that browsers are permitted to read.
*
* @return the immutable set of response headers exposed to the browser
*/
public Set<String> exposedHeaders() {
@@ -120,6 +126,8 @@ public final class CorsConfig {
}
/**
* Indicates whether credentialed (cookie/authorization) requests are permitted.
*
* @return {@code true} if credentialed requests are permitted
*/
public boolean allowCredentials() {
@@ -127,6 +135,8 @@ public final class CorsConfig {
}
/**
* Returns how long a preflight response may be cached by the browser.
*
* @return the preflight cache lifetime in seconds ({@code 0} disables the header)
*/
public long maxAgeSeconds() {
@@ -134,6 +144,8 @@ public final class CorsConfig {
}
/**
* Indicates whether requests from any origin are permitted.
*
* @return {@code true} if any origin is permitted
*/
public boolean allowAnyOrigin() {
@@ -160,6 +172,13 @@ public final class CorsConfig {
/** Whether any origin is permitted; defaults to {@code false}. */
private boolean allowAnyOrigin = false;
/**
* Creates a builder with no origins, methods or headers configured and all flags at
* their defaults. Obtain instances via {@link CorsConfig#builder()}.
*/
public Builder() {
}
/**
* Adds one or more explicit origins to the allow-list.
*
@@ -110,6 +110,13 @@ public final class RateLimitConfig {
/** The global rule, if configured. */
private Rule globalRule;
/**
* Creates a builder with no rules configured. Obtain instances via
* {@link RateLimitConfig#builder()}.
*/
public Builder() {
}
/**
* Sets the global rule applied to every request.
*
@@ -25,6 +25,13 @@ public final class Response {
/** Response body bytes; defaults to an empty array. */
private byte[] body = new byte[0];
/**
* Creates an empty response with status {@code 200}, no headers and an empty body, ready to
* be populated fluently by a handler.
*/
public Response() {
}
/**
* Sets the HTTP status code.
*
@@ -106,7 +113,7 @@ public final class Response {
/**
* Returns the response body bytes.
*
* @return the body
* @return the body bytes
*/
public byte[] body() { return body; }
}
@@ -34,6 +34,12 @@ public final class Router {
/** Middlewares executed in insertion order for every matched request. */
private final List<BiConsumer<Request, Response>> middlewares = new ArrayList<>();
/**
* Creates an empty router with no registered routes and no middlewares.
*/
public Router() {
}
/**
* Registers a middleware that runs against every matched request before its handler.
*
@@ -80,6 +80,8 @@ public final class WebSocketConfig {
}
/**
* Returns the maximum size of a single WebSocket frame payload.
*
* @return the maximum single-frame payload size in bytes
*/
public int maxFramePayloadLength() {
@@ -87,6 +89,8 @@ public final class WebSocketConfig {
}
/**
* Returns the maximum size of an aggregated (multi-frame) message.
*
* @return the maximum aggregated message size in bytes
*/
public int maxAggregatedMessageSize() {
@@ -94,6 +98,8 @@ public final class WebSocketConfig {
}
/**
* Returns the idle timeout after which inactive connections are closed.
*
* @return the idle timeout, or {@code null} if idle connections are never closed
*/
public Duration idleTimeout() {
@@ -101,6 +107,8 @@ public final class WebSocketConfig {
}
/**
* Indicates whether connections from any origin are accepted.
*
* @return {@code true} if connections from any origin are accepted
*/
public boolean allowAnyOrigin() {
@@ -108,6 +116,8 @@ public final class WebSocketConfig {
}
/**
* Returns the explicitly allowed origins.
*
* @return the immutable set of explicitly allowed origins
*/
public Set<String> allowedOrigins() {
@@ -126,6 +136,8 @@ public final class WebSocketConfig {
}
/**
* Indicates whether per-message deflate compression is enabled.
*
* @return {@code true} if per-message compression is enabled
*/
public boolean compression() {
@@ -133,6 +145,8 @@ public final class WebSocketConfig {
}
/**
* Indicates whether the WebSocket path is matched by prefix rather than exact equality.
*
* @return {@code true} if the WebSocket path is matched by prefix rather than exactly
*/
public boolean checkStartsWith() {
@@ -162,6 +176,13 @@ public final class WebSocketConfig {
/** Whether path matching uses a prefix check; defaults to {@code false}. */
private boolean checkStartsWith = false;
/**
* Creates a builder pre-populated with the default configuration values described
* above. Obtain instances via {@link WebSocketConfig#builder()}.
*/
public Builder() {
}
/**
* Sets the maximum single-frame payload size.
*
@@ -42,6 +42,8 @@ public final class WebSocketGroup {
}
/**
* Returns the name of this group.
*
* @return the group name
*/
public String name() {
@@ -71,6 +73,8 @@ public final class WebSocketGroup {
}
/**
* Returns how many connections are currently in the group.
*
* @return the current number of member connections
*/
public int size() {
@@ -19,6 +19,12 @@ public final class WebSocketRouter {
/** Root of the routing trie. */
private final Node root = new Node();
/**
* Creates an empty WebSocket router with no registered handlers.
*/
public WebSocketRouter() {
}
/**
* Registers a handler at the given path, creating any missing trie nodes. Segments wrapped
* in braces (e.g. {@code /chat/{room}}) are treated as path parameters.
@@ -66,6 +66,8 @@ public final class WebSocketSession {
}
/**
* Returns the unique identifier generated for this session.
*
* @return the unique session id
*/
public String id() {
@@ -73,6 +75,8 @@ public final class WebSocketSession {
}
/**
* Returns the path the connection was established on.
*
* @return the path the connection was established on
*/
public String path() {
@@ -90,6 +94,8 @@ public final class WebSocketSession {
}
/**
* Indicates whether the connection is still open.
*
* @return {@code true} if the underlying channel is still active (open)
*/
public boolean isOpen() {
@@ -111,6 +117,8 @@ public final class WebSocketSession {
}
/**
* Returns the underlying Netty channel for advanced, low-level use.
*
* @return the underlying Netty channel, for advanced use
*/
public Channel channel() {