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

getRequestFingerprint #536

Closed
1 task done
nandi95 opened this issue Sep 11, 2023 · 1 comment · Fixed by #548 or #564
Closed
1 task done

getRequestFingerprint #536

nandi95 opened this issue Sep 11, 2023 · 1 comment · Fixed by #548 or #564
Labels
enhancement New feature or request

Comments

@nandi95
Copy link
Contributor

nandi95 commented Sep 11, 2023

Describe the feature

I have made this helper function (taken from laravel) unjs/nitro#1705 (comment) that creates a hash based on the request. This can be useful to create some sort of identification of the request. which in turn can be used for numerous things (in my example it was to create a afterResponse hook).

import type { H3Event } from 'h3';
import crypto from 'crypto';

export default function getRequestFingerprint(event: H3Event): string {
    return crypto.createHash('sha1')
        .update(`${getRequestIP(event)}-${event.method}-${getRequestURL(event).toString()}`)
        .digest('hex');
}

Additional information

  • Would you be willing to help implement this feature?
@nandi95
Copy link
Contributor Author

nandi95 commented Sep 11, 2023

If set maybe the User-Agent header could be included too?

@pi0 pi0 added the enhancement New feature or request label Sep 26, 2023
nandi95 added a commit to nandi95/h3 that referenced this issue Sep 29, 2023
@renovate renovate bot closed this as completed in #548 Nov 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants