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(powered-by): optional server name #3492

Merged
merged 4 commits into from
Oct 15, 2024
Merged

Conversation

PatrickJS
Copy link
Contributor

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 Oct 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.57%. Comparing base (31b4cd4) to head (733e7bc).
Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3492      +/-   ##
==========================================
- Coverage   95.58%   95.57%   -0.02%     
==========================================
  Files         155      155              
  Lines        9357     9357              
  Branches     2730     2737       +7     
==========================================
- Hits         8944     8943       -1     
- Misses        413      414       +1     

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

@yusukebe yusukebe changed the title refactor(powered-by): optional server name feat(powered-by): optional server name Oct 6, 2024
@yusukebe
Copy link
Member

yusukebe commented Oct 6, 2024

Hi @PatrickJS

Thank you for the PR. This is good! It is a new feature but we can introduce it in the next patch release because it's not such a big change.

There should be tests. Can you add tests?

@yusukebe
Copy link
Member

@PatrickJS

I think making the option as an object, not a string, is good. Like the following:

diff --git a/src/middleware/powered-by/index.ts b/src/middleware/powered-by/index.ts
index caa3be7c..4db425f9 100644
--- a/src/middleware/powered-by/index.ts
+++ b/src/middleware/powered-by/index.ts
@@ -5,9 +5,13 @@

 import type { MiddlewareHandler } from '../../types'

-export const poweredBy = (serverName = 'Hono'): MiddlewareHandler => {
+type PoweredByOptions = {
+  serverName?: string
+}
+
+export const poweredBy = (options?: PoweredByOptions): MiddlewareHandler => {
   return async function poweredBy(c, next) {
     await next()
-    c.res.headers.set('X-Powered-By', serverName)
+    c.res.headers.set('X-Powered-By', options?.serverName ?? 'Hono')
   }
 }

@PatrickJS
Copy link
Contributor Author

ok made the changes thanks

@yusukebe
Copy link
Member

@PatrickJS

Thanks! Can you add a test?

@PatrickJS
Copy link
Contributor Author

yup just did 🫡

@PatrickJS
Copy link
Contributor Author

done done

Copy link
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@yusukebe
Copy link
Member

Thanks @PatrickJS !

Looks good. I'll merge this later and will include this change in the next patch release. It's a new feat but it's small. We don't have to wait for the release of the next minor version.

@yusukebe yusukebe merged commit fc9cc6d into honojs:main Oct 15, 2024
16 checks passed
@PatrickJS PatrickJS deleted the patch-1 branch October 15, 2024 03:57
TinsFox pushed a commit to TinsFox/hono that referenced this pull request Oct 28, 2024
* refactor(powered-by): optional server name

* style(powered-by): format

* test(powered-by): test new config

* Update index.test.ts
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.

2 participants