@Override
    public HttpResponse serve(ServiceRequestContext ctx, AggregatedHttpRequest req,
                              String defaultHostname, SamlPortConfig portConfig) {
        final HttpData metadata = metadataMap.computeIfAbsent(defaultHostname, h -> {
            try {
                final Element element =
                        SamlMessageUtil.serialize(buildMetadataEntityDescriptorElement(h, portConfig));
                final HttpData newMetadata = HttpData.ofUtf8(nodeToString(element));
                logger.debug("SAML service provider metadata has been prepared for: {}.", h);
                return newMetadata;
            } catch (Throwable cause) {
                logger.warn("{} Unexpected metadata request.", ctx, cause);
                return HttpData.empty();
            }
        });

        if (metadata != HttpData.empty()) {
            return HttpResponse.of(RESPONSE_HEADERS, metadata);
        } else {
            return HttpResponse.of(HttpStatus.NOT_FOUND);
        }
    }
A service which returns the SAML metadata in response to a user request.
saml/src/main/java/com/linecorp/armeria/server/saml/SamlMetadataServiceFunction.java