-
I would like to do something like this: app.use(async ctx => {
if (await send(ctx, ctx.request.url.pathname, {root: './assets'}) != undefined) await send(ctx, ctx.request.url.pathname, {root: './assets'})
else ctx.response.body = '404'
}) Any idea? |
Beta Was this translation helpful? Give feedback.
Answered by
Hunam6
May 9, 2021
Replies: 1 comment
-
Sorry my bad, nothing to do with Oak, just use import {exists} from 'https://deno.land/std/fs/mod.ts'
app.use(async ctx => {
if (await exists('./assets' + ctx.request.url.pathname)) await send(ctx, ctx.request.url.pathname, {root: './assets'})
else {
ctx.response.body = 'error 404'
ctx.response.status = 404
}
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Hunam6
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry my bad, nothing to do with Oak, just use
fs
.If anyone intrested: