use activitystreams::iri_string::types::IriString;
use actix_web::{HttpResponse, web::Data};
use crate::config::{Config, UrlKind};
pub(crate) async fn route(config: Data<Config>) -> HttpResponse {
let webfinger = config.generate_url(UrlKind::Webfinger);
HttpResponse::Ok()
.content_type("application/xrd+xml")
.body(xml(&webfinger))
}
fn xml(webfinger: &IriString) -> String {
format!(
r#"<?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
<Link rel="lrdd" template="{webfinger}?resource={{uri}}"/>
</XRD>"#
)
}