Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(serve-static): add onFound option #3396

Merged
merged 2 commits into from
Sep 10, 2024
Merged

Conversation

yusukebe
Copy link
Member

@yusukebe yusukebe commented Sep 8, 2024

This PR introduces the onFound option for Serve Static Middleware.

If you want to add a custom header to found files, you can write the following:

app.get(
  '/static/*',
  serveStatic({
    // ... 
    onFound: (_path, c) => {
      c.header('Cache-Control', `public, immutable, max-age=31536000`)
    },
  })
)

Related to #3395 honojs/node-server#195

The author should do the following, if applicable

  • Add tests
  • Run tests
  • bun run format:fix && bun run lint:fix to format the code
  • Add TSDoc/JSDoc to document the code

Copy link

codecov bot commented Sep 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.77%. Comparing base (c2b0de4) to head (0727db2).
Report is 2 commits behind head on next.

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #3396   +/-   ##
=======================================
  Coverage   95.77%   95.77%           
=======================================
  Files         154      154           
  Lines        9271     9272    +1     
  Branches     2725     2743   +18     
=======================================
+ Hits         8879     8880    +1     
  Misses        392      392           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant