Skip to content

Commit

Permalink
Review: mark->value, docs
Browse files Browse the repository at this point in the history
  • Loading branch information
snazy committed Oct 2, 2023
1 parent e25154e commit 938d9e3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 30 deletions.
18 changes: 8 additions & 10 deletions docs/src/main/asciidoc/http-reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -591,21 +591,19 @@ link:https://undertow.io/undertow-docs/undertow-docs-2.0.0/index.html#predicates

If you are using a `web.xml` file as your configuration file, you can place it in the `src/main/resources/META-INF` directory.

== References
=== Built-in route order values

=== Well-known route order values
Route order values are the values that are specified via Vert.x route `io.vertx.ext.web.Route.order(int)` function.

Route order marks are the values that are specified via Vert.x route `io.vertx.ext.web.Route.order(int)` function.

Quarkus uses a couple of route order marks itself. Your route order mark values should be at least a positive integer
value above `20000` (see `RouteConstants.ROUTE_ORDER_AFTER_DEFAULT_MARK`) to not interfere with the functionality provided
by Quarkus or its extensions.
Quarkus registers a couple of routes with specific order values.
The constants are defined in the `io.quarkus.vertx.http.runtime.RouteConstants` class and listed in the table below.
A custom route should define the order of value 20000 or higher so that it does not interfere with the functionality provided by Quarkus and extensions.

Route order constants defined in `io.quarkus.vertx.http.runtime.RouteConstants` and known extensions:

[cols="1,1,3"]
|===
| Route order mark| Constant name| Origin
| Route order value| Constant name| Origin
| `Integer.MIN_VALUE` | `ROUTE_ORDER_ACCESS_LOG_HANDLER` | Access-log handler, if enabled in the configuration.
| `Integer.MIN_VALUE` | `ROUTE_ORDER_RECORD_START_TIME` | Handler adding the start-time, if enabled in the configuration.
| `Integer.MIN_VALUE` | `ROUTE_ORDER_HOT_REPLACEMENT` | -replacement body handler.
Expand All @@ -615,7 +613,7 @@ Route order constants defined in `io.quarkus.vertx.http.runtime.RouteConstants`
| `Integer.MIN_VALUE + 1` | `ROUTE_ORDER_BODY_HANDLER` | Body handler.
| `-2` | `ROUTE_ORDER_UPLOAD_LIMIT` | Route that enforces the upload body size limit.
| `0` | `ROUTE_ORDER_COMPRESSION` | Compression handler.
| `1000` | `ROUTE_ORDER_BEFORE_DEFAULT_MARK` | Route with priority over the default route (add an offset from this mark).
| `1000` | `ROUTE_ORDER_BEFORE_DEFAULT` | Route with priority over the default route (add an offset from this value).
| `10000` | `ROUTE_ORDER_DEFAULT` | Default route order (i.e. Static Resources, Servlet).
| `20000` | `ROUTE_ORDER_AFTER_DEFAULT_MARK` | Route without priority over the default route (add an offset from this mark)
| `20000` | `ROUTE_ORDER_AFTER_DEFAULT` | Route without priority over the default route (add an offset from this value)
|===
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void boot(ShutdownContextBuildItem shutdown,
routes.produce(
RouteBuildItem.builder()
.orderedRoute(standalone.deploymentRootPath,
RouteConstants.ROUTE_ORDER_AFTER_DEFAULT_MARK + REST_ROUTE_ORDER_OFFSET)
RouteConstants.ROUTE_ORDER_AFTER_DEFAULT + REST_ROUTE_ORDER_OFFSET)
.handler(handler).build());
String matchPath = standalone.deploymentRootPath;
if (matchPath.endsWith("/")) {
Expand All @@ -146,7 +146,7 @@ public void boot(ShutdownContextBuildItem shutdown,
}
// Match paths that begin with the deployment path
routes.produce(RouteBuildItem.builder()
.orderedRoute(matchPath, RouteConstants.ROUTE_ORDER_AFTER_DEFAULT_MARK + REST_ROUTE_ORDER_OFFSET)
.orderedRoute(matchPath, RouteConstants.ROUTE_ORDER_AFTER_DEFAULT + REST_ROUTE_ORDER_OFFSET)
.handler(handler).build());

recorder.start(shutdown, requireVirtual.isPresent());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1251,11 +1251,11 @@ public void setupDeployment(BeanContainerBuildItem beanContainerBuildItem,
.produce(new ResteasyReactiveDeploymentInfoBuildItem(deploymentInfo));

boolean servletPresent = false;
int order = RouteConstants.ROUTE_ORDER_AFTER_DEFAULT_MARK + REST_ROUTE_ORDER_OFFSET;
int order = RouteConstants.ROUTE_ORDER_AFTER_DEFAULT + REST_ROUTE_ORDER_OFFSET;
if (capabilities.isPresent("io.quarkus.servlet")) {
//if servlet is present we run RR before the default route
//otherwise we run after it
order = RouteConstants.ROUTE_ORDER_BEFORE_DEFAULT_MARK + REST_ROUTE_ORDER_OFFSET;
order = RouteConstants.ROUTE_ORDER_BEFORE_DEFAULT + REST_ROUTE_ORDER_OFFSET;
servletPresent = true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
package io.quarkus.vertx.http.runtime;

/**
* Route order mark constants used in Quarkus, update {@code reactive-routes.adoc} when changing this class.
* Route order value constants used in Quarkus, update {@code reactive-routes.adoc} when changing this class.
*/
@SuppressWarnings("JavadocDeclaration")
public final class RouteConstants {
private RouteConstants() {
}

/**
* Order mark ({@value #ROUTE_ORDER_ACCESS_LOG_HANDLER}) for the access-log handler, if enabled in the configuration.
* Order value ({@value #ROUTE_ORDER_ACCESS_LOG_HANDLER}) for the access-log handler, if enabled in the configuration.
*/
public static final int ROUTE_ORDER_ACCESS_LOG_HANDLER = Integer.MIN_VALUE;
/**
* Order mark ({@value #ROUTE_ORDER_RECORD_START_TIME}) for the handler adding the start-time, if enabled in the
* Order value ({@value #ROUTE_ORDER_RECORD_START_TIME}) for the handler adding the start-time, if enabled in the
* configuration.
*/
public static final int ROUTE_ORDER_RECORD_START_TIME = Integer.MIN_VALUE;
/**
* Order mark ({@value #ROUTE_ORDER_HOT_REPLACEMENT}) for the hot-replacement body handler.
* Order value ({@value #ROUTE_ORDER_HOT_REPLACEMENT}) for the hot-replacement body handler.
*/
public static final int ROUTE_ORDER_HOT_REPLACEMENT = Integer.MIN_VALUE;
/**
* Order mark ({@value #ROUTE_ORDER_BODY_HANDLER_MANAGEMENT}) for the body handler for the management router.
* Order value ({@value #ROUTE_ORDER_BODY_HANDLER_MANAGEMENT}) for the body handler for the management router.
*/
public static final int ROUTE_ORDER_BODY_HANDLER_MANAGEMENT = Integer.MIN_VALUE;
/**
* Order mark ({@value #ROUTE_ORDER_HEADERS}) for the handlers that add headers specified in the configuration.
* Order value ({@value #ROUTE_ORDER_HEADERS}) for the handlers that add headers specified in the configuration.
*/
public static final int ROUTE_ORDER_HEADERS = Integer.MIN_VALUE;
/**
* Order mark ({@value #ROUTE_ORDER_CORS_MANAGEMENT}) for the CORS-Origin handler of the management router.
* Order value ({@value #ROUTE_ORDER_CORS_MANAGEMENT}) for the CORS-Origin handler of the management router.
*/
public static final int ROUTE_ORDER_CORS_MANAGEMENT = Integer.MIN_VALUE;
/**
* Order mark ({@value #ROUTE_ORDER_BODY_HANDLER}) for the body handler.
* Order value ({@value #ROUTE_ORDER_BODY_HANDLER}) for the body handler.
*/
public static final int ROUTE_ORDER_BODY_HANDLER = Integer.MIN_VALUE + 1;
/**
* Order mark ({@value #ROUTE_ORDER_UPLOAD_LIMIT}) for the route that enforces the upload body size limit.
* Order value ({@value #ROUTE_ORDER_UPLOAD_LIMIT}) for the route that enforces the upload body size limit.
*/
public static final int ROUTE_ORDER_UPLOAD_LIMIT = -2;
/**
* Order mark ({@value #ROUTE_ORDER_COMPRESSION}) for the compression handler.
* Order value ({@value #ROUTE_ORDER_COMPRESSION}) for the compression handler.
*/
public static final int ROUTE_ORDER_COMPRESSION = 0;
/**
* Order mark ({@value #ROUTE_ORDER_BEFORE_DEFAULT_MARK}) for route with priority over the default route (add an offset from
* this mark)
* Order value ({@value #ROUTE_ORDER_BEFORE_DEFAULT}) for route with priority over the default route (add an offset from
* this value)
*/
public static final int ROUTE_ORDER_BEFORE_DEFAULT_MARK = 1_000;
public static final int ROUTE_ORDER_BEFORE_DEFAULT = 1_000;
/**
* Default route order (i.e. Static Resources, Servlet): ({@value #ROUTE_ORDER_DEFAULT})
*/
public static final int ROUTE_ORDER_DEFAULT = 10_000;
/**
* Order mark ({@value #ROUTE_ORDER_AFTER_DEFAULT_MARK}) for route without priority over the default route (add an offset
* from this mark)
* Order value ({@value #ROUTE_ORDER_AFTER_DEFAULT}) for route without priority over the default route (add an offset
* from this value)
*/
public static final int ROUTE_ORDER_AFTER_DEFAULT_MARK = 20_000;
public static final int ROUTE_ORDER_AFTER_DEFAULT = 20_000;
}

0 comments on commit 938d9e3

Please sign in to comment.