Some progress towards accepting and rejecting follows #3
3 changed files with 27 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
|||
import { getLogger } from "@logtape/logtape"
|
||||
import { handleHostMeta } from "../dv/hostMeta.ts"
|
||||
import { DotinoVeloce } from "../dv/dotinoVeloce.ts"
|
||||
import { handleFavicon } from "../dv/favicon.ts"
|
||||
|
||||
|
||||
const l = getLogger(["dotino-veloce", "deno", "router"])
|
||||
|
@ -21,15 +22,19 @@ export function createRouter(ap: DotinoVeloce) {
|
|||
const pathname = url.pathname
|
||||
l.debug`Request's pathname is: ${pathname}`
|
||||
|
||||
if (url.pathname === "/favicon.ico") {
|
||||
l.debug`Delegating handling to favicon handler...`
|
||||
return await handleFavicon()
|
||||
}
|
||||
if (url.pathname === "/.well-known/host-meta")
|
||||
{
|
||||
l.debug`Delegating handling to host-meta generator...`
|
||||
return handleHostMeta(url.origin)
|
||||
return await handleHostMeta(url.origin)
|
||||
}
|
||||
else
|
||||
{
|
||||
l.debug`Delegating request to Fedify...`
|
||||
return ap.federation.fetch(
|
||||
return await ap.federation.fetch(
|
||||
request,
|
||||
{
|
||||
contextData: undefined,
|
||||
|
|
18
src/dv/favicon.ts
Normal file
18
src/dv/favicon.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import { getLogger } from "@logtape/logtape"
|
||||
|
||||
|
||||
const l = getLogger(["dotino-veloce", "ap", "favicon"])
|
||||
|
||||
|
||||
export async function handleFavicon(): Promise<Response> {
|
||||
l.info`Returning favicon...`
|
||||
|
||||
return new Response(
|
||||
await Deno.readFile(".media/icon-128x128_round.png"),
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "image/png",
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
|
@ -4,7 +4,8 @@ import { getLogger } from "@logtape/logtape"
|
|||
const l = getLogger(["dotino-veloce", "ap", "hostMeta"])
|
||||
|
||||
|
||||
export function handleHostMeta(origin: string): Response {
|
||||
// deno-lint-ignore require-await
|
||||
export async function handleHostMeta(origin: string): Promise<Response> {
|
||||
l.info`Creating host-meta definition for: ${origin}`
|
||||
|
||||
// Akkoma expects host-meta to be correctly setup
|
||||
|
|
Loading…
Reference in a new issue