private void serveAsync(ServiceRequestContext ctx, AbstractResteasyHttpRequest<?> request,
                            ResteasyHttpResponseImpl response) {
        final ResteasyProviderFactory defaultInstance = ResteasyProviderFactory.getInstance();
        if (defaultInstance instanceof ThreadLocalResteasyProviderFactory) {
            ThreadLocalResteasyProviderFactory.push(providerFactory);
        }
        try {
            // manage SecurityContext
            final SecurityContext securityContext;
            if (securityDomain != null) {
                final BasicToken basicToken = AuthTokenExtractors.basic().apply(request.requestHeaders());
                if (basicToken == null) {
                    // no Basic Authorization present, e.g. "Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l"
                    // respond with "Basic" authentication request
                    response.getOutputHeaders().add(HttpHeaderNames.WWW_AUTHENTICATE.toString(), "Basic");
                    response.sendError(HttpResponseCodes.SC_UNAUTHORIZED);
                    response.finish();
                    return;
                }

                final Principal principal;
                try {
                    principal = securityDomain.authenticate(basicToken.username(), basicToken.password());
                } catch (SecurityException e) {
                    // provided Basic Authorization is not authenticated successfully
                    response.sendError(HttpResponseCodes.SC_UNAUTHORIZED);
                    response.finish();
                    return;
                }

                securityContext = SecurityContextImpl.basic(principal, securityDomain);
            } else {
                securityContext = SecurityContextImpl.insecure();
            }

            ResteasyContext.pushContext(SecurityContext.class,
                                        securityContext); // should we set unsecure context?
            if (contextConverter != null) {
                ResteasyContext.pushContext(contextClass, contextConverter.apply(ctx));
            } else {
                ResteasyContext.pushContext(ServiceRequestContext.class, ctx);
            }
            try {
                dispatcher.invoke(request, response);
            } finally {
                ResteasyContext.clearContextData();
            }
            if (!request.getAsyncContext().isSuspended()) {
                response.finish();
            }
        } finally {
            if (defaultInstance instanceof ThreadLocalResteasyProviderFactory) {
                ThreadLocalResteasyProviderFactory.pop();
            }
        }
    }
Registers {@link ResteasyService} with Armeria {@link ServerBuilder}.
resteasy/src/main/java/com/linecorp/armeria/server/resteasy/ResteasyService.java