protected abstract void handleInternal()

in server/src/main/java/org/apache/cassandra/sidecar/handlers/AbstractHandler.java [116:168]


    protected abstract void handleInternal(RoutingContext context,
                                           HttpServerRequest httpRequest,
                                           @NotNull String host,
                                           SocketAddress remoteAddress,
                                           T request);

    /**
     * Returns the host from the path if the requests contains the {@code /instance/} path parameter,
     * otherwise it returns the host parsed from the request.
     *
     * @param context the routing context
     * @return the host for the routing context
     * @throws HttpException when the {@code /instance/} path parameter is {@code null}
     */
    @NotNull
    public String host(RoutingContext context)
    {
        if (context.request().params().contains(INSTANCE_ID))
        {
            String instanceIdParam = context.request().getParam(INSTANCE_ID);
            if (instanceIdParam == null)
            {
                throw new HttpException(HttpResponseStatus.BAD_REQUEST.code(),
                                        "InstanceId query parameter must be provided");
            }

            try
            {
                int instanceId = Integer.parseInt(instanceIdParam);
                return metadataFetcher.instance(instanceId).host();
            }
            catch (NumberFormatException ex)
            {
                throw new HttpException(HttpResponseStatus.BAD_REQUEST.code(),
                                        "InstanceId query parameter must be a valid integer");
            }
            catch (NoSuchCassandraInstanceException | IllegalStateException ex)
            {
                throw new HttpException(HttpResponseStatus.NOT_FOUND.code(), ex.getMessage());
            }
        }
        else
        {
            try
            {
                return extractHostAddressWithoutPort(context.request());
            }
            catch (IllegalArgumentException ex)
            {
                throw new HttpException(HttpResponseStatus.BAD_REQUEST.code(), ex.getMessage());
            }
        }
    }