Add host-meta endpoint

This commit is contained in:
Jesse Wierzbinski 2023-09-12 19:33:08 -10:00
parent a83648db48
commit a499dfd231
No known key found for this signature in database
GPG key ID: F9A1E418934E40B0
2 changed files with 27 additions and 0 deletions

View file

@ -0,0 +1,18 @@
import { MatchedRoute } from "bun";
import { getHost } from "@config";
import { xmlResponse } from "@response";
/**
* Host meta endpoint
*/
export default async (
req: Request,
matchedRoute: MatchedRoute
): Promise<Response> => {
return xmlResponse(`
<?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
<Link rel="lrdd" template="https://${getHost()}/.well-known/webfinger?resource={uri}"/>
</XRD>
`);
};

View file

@ -10,6 +10,15 @@ export const jsonResponse = (data: object, status = 200) => {
});
};
export const xmlResponse = (data: string, status = 200) => {
return new Response(data, {
headers: {
"Content-Type": "application/xml",
},
status,
});
};
export const jsonLdResponse = (
data: NodeObject | APActivity | APObject,
status = 200