From 8be179c7d5c42cb6a60a7a981eb34e9a3c04a882 Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Wed, 11 Sep 2024 15:09:52 +0900 Subject: [PATCH] docs(serve-static/deno,bun): add `onFound` (#485) --- docs/getting-started/bun.md | 16 ++++++++++++++++ docs/getting-started/deno.md | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/docs/getting-started/bun.md b/docs/getting-started/bun.md index 9779395b..760ce7c6 100644 --- a/docs/getting-started/bun.md +++ b/docs/getting-started/bun.md @@ -135,6 +135,22 @@ app.get( ) ``` +### `onFound` + +You can specify handling when the requested file is found with `onFound`: + +```ts +app.get( + '/static/*', + serveStatic({ + // ... + onFound: (_path, c) => { + c.header('Cache-Control', `public, immutable, max-age=31536000`) + }, + }) +) +``` + ### `onNotFound` You can specify handling when the requested file is not found with `onNotFound`: diff --git a/docs/getting-started/deno.md b/docs/getting-started/deno.md index 998ece9c..a098ae0a 100644 --- a/docs/getting-started/deno.md +++ b/docs/getting-started/deno.md @@ -122,6 +122,22 @@ app.get( ) ``` +### `onFound` + +You can specify handling when the requested file is found with `onFound`: + +```ts +app.get( + '/static/*', + serveStatic({ + // ... + onFound: (_path, c) => { + c.header('Cache-Control', `public, immutable, max-age=31536000`) + }, + }) +) +``` + ### `onNotFound` You can specify handling when the requested file is not found with `onNotFound`: