@ChannelHandler.Sharable
public class Router
extends io.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.FullHttpRequest>
The Router itself has the same granularity as HttpServer: one instance only.
When matching a route, priority is first given to built-in routes, only if none match the first matching instance-specific dynamic route is matched. Dynamic routes often mention ':instance' in their url, which will be expanded upon registration into the actual yamcs instance.
| Modifier and Type | Class and Description |
|---|---|
static class |
Router.RouteConfig
Struct containing all non-path route configuration
|
static class |
Router.RouteMatch
Represents a matched route pattern
|
| Modifier and Type | Field and Description |
|---|---|
static io.netty.util.AttributeKey<Router.RouteMatch> |
CTX_ROUTE_MATCH |
static int |
MAX_BODY_SIZE |
| Constructor and Description |
|---|
Router() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
channelRead0(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http.FullHttpRequest req) |
protected void |
dispatch(RestRequest req,
Router.RouteMatch match) |
void |
exceptionCaught(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause) |
Router.RouteMatch |
matchURI(io.netty.handler.codec.http.HttpMethod method,
String uri) |
void |
registerRouteHandler(String yamcsInstance,
RouteHandler routeHandler) |
boolean |
scheduleExecution(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http.HttpRequest req,
io.netty.handler.codec.http.QueryStringDecoder qsDecoder)
At this point we do not have the full request (only the header) so we have to configure the pipeline either for
receiving the full request or with route specific pipeline for receiving (large amounts of) data in case of
dataLoad routes.
|
acceptInboundMessage, channelReadchannelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggeredensureNotSharable, handlerAdded, handlerRemoved, isSharablepublic static final int MAX_BODY_SIZE
public static final io.netty.util.AttributeKey<Router.RouteMatch> CTX_ROUTE_MATCH
public void registerRouteHandler(String yamcsInstance, RouteHandler routeHandler)
public boolean scheduleExecution(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http.HttpRequest req,
io.netty.handler.codec.http.QueryStringDecoder qsDecoder)
ctx - req - qsDecoder - protected void channelRead0(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http.FullHttpRequest req)
throws Exception
channelRead0 in class io.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.FullHttpRequest>Exceptionpublic Router.RouteMatch matchURI(io.netty.handler.codec.http.HttpMethod method, String uri) throws MethodNotAllowedException
MethodNotAllowedExceptionprotected void dispatch(RestRequest req, Router.RouteMatch match)
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause)
throws Exception
exceptionCaught in interface io.netty.channel.ChannelHandlerexceptionCaught in interface io.netty.channel.ChannelInboundHandlerexceptionCaught in class io.netty.channel.ChannelInboundHandlerAdapterExceptionCopyright © 2018 Space Applications Services. All rights reserved.